Class GuiManager


  • public class GuiManager
    extends java.lang.Object
    Maintains the application's main GUI state.
    • 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 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 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 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 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 prompt
        queryType - 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; false if 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 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 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 name
        characterName - the character name