public class GuiManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GuiManager.EscAction
Action after ESC has been pressed.
|
Modifier and Type | Field and Description |
---|---|
private JXCConnection |
connection
The
JXCConnection to use. |
private CrossfireDrawextinfoListener |
crossfireDrawextinfoListener
The
CrossfireDrawextinfoListener attached to server . |
private CrossfireFailureListener |
crossfireFailureListener
The
CrossfireFailureListener registered to receive failure
messages. |
private boolean |
currentQueryDialogIsNamePrompt
Whether the currently shown query dialog is the character name prompt.
|
private Gui |
dialogConnect
The "connect in progress" dialog.
|
private AbstractLabel |
dialogConnectLabel
The "message" field within
dialogConnect . |
private Gui |
dialogDisconnect
The "really disconnect?" dialog.
|
private Gui |
dialogQuit
The "really quit?" dialog.
|
private java.util.Map<java.lang.String,Gui> |
dialogs
Maps dialog name to dialog instance.
|
private GuiFactory |
guiFactory
The
GuiFactory for creating Gui instances. |
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private Gui |
keybindDialog
The keybindings dialog.
|
private KeybindingsManager |
keybindingsManager
The key bindings manager for this window.
|
private Gui |
queryDialog
The query dialog.
|
private CrossfireServerConnection |
server
The
CrossfireServerConnection instance to monitor. |
private Settings |
settings
The
Settings to use. |
private JXCSkin |
skin
The currently active skin.
|
private TooltipManagerImpl |
tooltipManager
The
TooltipManager for this window. |
private JXCWindowRenderer |
windowRenderer
The
JXCWindowRenderer used to paint the gui. |
Constructor and Description |
---|
GuiManager(GuiStateManager guiStateManager,
TooltipManagerImpl tooltipManager,
Settings settings,
CrossfireServerConnection server,
JXCWindowRenderer windowRenderer,
GuiFactory guiFactory,
KeybindingsManager keybindingsManager,
JXCConnection connection)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private GUIText |
activateCommandInput()
Activates the command input text field.
|
void |
activateCommandInput(java.lang.String newText)
Activates the command input text field.
|
private void |
activateMetaserverGui()
Called when the server selection GUI becomes active.
|
void |
addDialog(java.lang.String name,
Gui dialog)
Adds a dialog for name based lookup.
|
boolean |
closeDialog(Gui dialog)
Closes the given dialog.
|
void |
closeDialog(java.lang.String name)
Closes the given dialog.
|
private void |
closeDialogByName(java.lang.String name)
Closes a dialog by name.
|
void |
closeKeybindDialog()
Closes the keybinding dialog.
|
void |
closeQueryDialog()
Closes the "query" dialog.
|
private void |
closeTransientDialogs()
Closes all transient dialogs: disconnect, quit, connect, query, and book
dialogs.
|
boolean |
createKeyBinding(boolean perCharacter,
CommandList cmdList)
Adds a key binding.
|
GuiManager.EscAction |
escPressed(boolean connected)
The ESC key has been pressed.
|
CommandList |
getCommandList(java.lang.String args)
Returns a named command list.
|
void |
hideAccountWindows()
Hides all account-related windows.
|
void |
manageAccount()
Displays the main account dialog, to let the player login or create a new
account.
|
private boolean |
openDialog(Gui dialog,
boolean autoCloseOnDeactivate)
Opens a dialog.
|
void |
openDialog(java.lang.String name)
Opens a dialog by name.
|
private boolean |
openDialogByName(java.lang.String name)
Opens a dialog by name.
|
private void |
openKeybindDialog()
Opens the keybinding dialog.
|
void |
openQueryDialog(java.lang.String prompt,
int queryType)
Opens the "query" dialog.
|
boolean |
openQuitDialog()
Opens the "quit" dialog.
|
void |
playerReceived()
A "player" protocol command has been received.
|
boolean |
removeKeyBinding(boolean perCharacter)
Removes a key binding.
|
void |
selectCharacter(java.lang.String accountName,
java.lang.String characterName)
Updates the selected character name in an account.
|
void |
setAccountName(java.lang.String accountName)
Updates the current account name.
|
private void |
setHideInput(boolean hideInput)
Enables or disables hidden text in the first input field of the
queryDialog . |
void |
setSkin(JXCSkin skin)
Sets a new skin.
|
void |
showCharacters(int count)
Displays the window with the characters for an account.
|
private void |
showGUIMain()
Displays the "main" GUI.
|
private void |
showGUIMeta()
Displays the "server selection" GUI.
|
private void |
showGUIStart()
Displays the "start" GUI.
|
void |
term()
Terminates the GUI.
|
void |
toggleDialog(java.lang.String name)
Toggles a dialog.
|
void |
unsetSkin()
Unsets the current skin.
|
private void |
updateConnectLabel(ClientSocketState clientSocketState,
java.lang.String param)
Updates the "message" field of the connect dialog.
|
void |
updatePlayerName(java.lang.String playerName)
Sets the current player name.
|
void |
updateWindowSize(int width,
int height)
Sets a new window size.
|
@NotNull private final JXCConnection connection
JXCConnection
to use.@NotNull private final CrossfireDrawextinfoListener crossfireDrawextinfoListener
CrossfireDrawextinfoListener
attached to server
.@NotNull private final CrossfireFailureListener crossfireFailureListener
CrossfireFailureListener
registered to receive failure
messages.private boolean currentQueryDialogIsNamePrompt
@Nullable private Gui dialogConnect
null
if the skin does
not define this dialog.@Nullable private AbstractLabel dialogConnectLabel
dialogConnect
. Set to null
if
the dialog does not define a "message" label.@Nullable private Gui dialogDisconnect
null
if the skin does not
define this dialog.@Nullable private Gui dialogQuit
null
if the skin does not
define this dialog.@NotNull private final java.util.Map<java.lang.String,Gui> dialogs
@NotNull private final GuiFactory guiFactory
GuiFactory
for creating Gui
instances.@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@Nullable private Gui keybindDialog
@NotNull private final KeybindingsManager keybindingsManager
@Nullable private Gui queryDialog
@NotNull private final CrossfireServerConnection server
CrossfireServerConnection
instance to monitor.@Nullable private JXCSkin skin
null
if no skin is set.@NotNull private final TooltipManagerImpl tooltipManager
TooltipManager
for this window.@NotNull private final JXCWindowRenderer windowRenderer
JXCWindowRenderer
used to paint the gui.public 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)
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@Nullable private GUIText activateCommandInput()
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.
null
if the skin has no
command input text field definedpublic void activateCommandInput(@Nullable java.lang.String newText)
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.
newText
- the new command text if non-null
private void activateMetaserverGui()
public void addDialog(@NotNull java.lang.String name, @NotNull Gui dialog)
name
- the name of the dialogdialog
- the dialogpublic boolean closeDialog(@NotNull Gui dialog)
dialog
- the dialog to closefalse
if the dialog
was not openpublic void closeDialog(@NotNull java.lang.String name)
name
- the name of the dialogprivate void closeDialogByName(@NotNull java.lang.String name)
name
- the dialog namepublic void closeKeybindDialog()
public void closeQueryDialog()
private void closeTransientDialogs()
public boolean createKeyBinding(boolean perCharacter, @NotNull CommandList cmdList)
perCharacter
- whether a per-character key binding should be addedcmdList
- the command list to execute on key presspublic GuiManager.EscAction escPressed(boolean connected)
connected
- whether a connection to the server is active@NotNull public CommandList getCommandList(@NotNull java.lang.String args) throws NoSuchCommandException
args
- the name of the command listNoSuchCommandException
- if the command list does not existpublic void hideAccountWindows()
public void manageAccount()
private boolean openDialog(@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 openDialog(@NotNull java.lang.String name)
name
- the name of the dialogprivate boolean openDialogByName(@NotNull java.lang.String name)
name
- the dialog nameprivate void openKeybindDialog()
public void openQueryDialog(@NotNull java.lang.String prompt, int queryType)
prompt
- the query promptqueryType
- the query typepublic boolean openQuitDialog()
public void playerReceived()
public boolean removeKeyBinding(boolean perCharacter)
perCharacter
- whether a per-character key binding should be
removedpublic void selectCharacter(@NotNull java.lang.String accountName, @NotNull java.lang.String characterName)
accountName
- the account namecharacterName
- the character namepublic void setAccountName(@NotNull java.lang.String accountName)
accountName
- the current account nameprivate void setHideInput(boolean hideInput)
queryDialog
.hideInput
- if set, hide input; else show inputpublic void setSkin(@NotNull JXCSkin skin)
skin
- the new skinpublic void showCharacters(int count)
count
- how many characters the account has.private void showGUIMain()
private void showGUIMeta()
private void showGUIStart()
public void term()
public void toggleDialog(@NotNull java.lang.String name)
name
- the name of the dialogpublic void unsetSkin()
private void updateConnectLabel(@NotNull ClientSocketState clientSocketState, @Nullable java.lang.String param)
clientSocketState
- the client socket stateparam
- a parameter to displaypublic void updatePlayerName(@NotNull java.lang.String playerName)
playerName
- the player namepublic void updateWindowSize(int width, int height)
width
- the new window widthheight
- the new window height