Class GuiManager

java.lang.Object
com.realtime.crossfire.jxclient.window.GuiManager

public class GuiManager extends Object
Maintains the application's main GUI state.
  • 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 watch
      tooltipManager - the tooltip manager to update
      settings - the settings to use
      server - the crossfire server connection to monitor
      windowRenderer - the window renderer to use
      guiFactory - the gui factory for creating gui instances
      keybindingsManager - the keybindings manager to use
      connection - the connection to use
  • Method Details

    • addDialog

      public void addDialog(@NotNull @NotNull String name, @NotNull @NotNull Gui dialog)
      Adds a dialog for name based lookup.
      Parameters:
      name - the name of the dialog
      dialog - 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 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 String prompt, int queryType)
      Opens the "query" dialog.
      Parameters:
      prompt - the query prompt
      queryType - the query type
    • openDialog

      public void openDialog(@NotNull @NotNull 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 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 String name)
      Closes the given dialog. Does nothing if the dialog is not opened.
      Parameters:
      name - the name of the dialog
    • updatePlayerName

      public void updatePlayerName(@NotNull @NotNull 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 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 added
      cmdList - 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 width
      height - 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

      @NotNull public @NotNull Collection<String> getCommandListNames()
      Returns all names of command lists.
      Returns:
      the names in alphabetical order
    • setAccountName

      public void setAccountName(@NotNull @NotNull String accountName)
      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 name
      characterName - 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