Class ClientOptions

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<FreeColObject>, ObjectWithId, Option<OptionGroup>, OptionContainer

    public class ClientOptions
    extends OptionGroup
    Defines how available client options are displayed on the Setting dialog from File/Preferences Also contains several Comparators used for display purposes. Most available client options and their default values are defined in the file base/client-options.xml in the FreeCol data directory. They are overridden by the player's personal settings in the file options.xml in the user directory. Note that some options are generated and added dynamically. Each option should be given an unique identifier (defined as a constant in this class). In general, the options are called something like "model.option.UNIQUENAME". Since the options must also be represented by the GUI, they following two keys must be added to the file FreeColMessages.properties:
    • model.option.UNIQUENAME.name
    • model.option.UNIQUENAME.shortDescription
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • NAME

        public static final java.lang.String NAME
        Option for the player's preferred name.
        See Also:
        Constant Field Values
      • LANGUAGE

        public static final java.lang.String LANGUAGE
        Special option for setting the language.
        See Also:
        Constant Field Values
      • AUTOMATIC

        public static final java.lang.String AUTOMATIC
        Value for automatic language selection.
        See Also:
        Constant Field Values
      • DISPLAY_SCALING

        public static final java.lang.String DISPLAY_SCALING
        Option to control the display scale factor.
        See Also:
        Constant Field Values
      • MANUAL_MAIN_FONT_SIZE

        public static final java.lang.String MANUAL_MAIN_FONT_SIZE
        Enable manual override of main font size.
        See Also:
        Constant Field Values
      • MAIN_FONT_SIZE

        public static final java.lang.String MAIN_FONT_SIZE
        Value to use to override the main font size, if enabled by the above.
        See Also:
        Constant Field Values
      • USE_PIXMAPS

        public static final java.lang.String USE_PIXMAPS
        Pixmap setting to work around Java 2D graphics bug.
        See Also:
        Constant Field Values
      • USE_OPENGL

        public static final java.lang.String USE_OPENGL
        Enable use of openGL pipeline.
        See Also:
        Constant Field Values
      • USE_XRENDER

        public static final java.lang.String USE_XRENDER
        Enable use of XRender pipeline (unix specific).
        See Also:
        Constant Field Values
      • MOVE_ANIMATION_SPEED

        public static final java.lang.String MOVE_ANIMATION_SPEED
        Animation speed for our units.
        See Also:
        Constant Field Values
      • ENEMY_MOVE_ANIMATION_SPEED

        public static final java.lang.String ENEMY_MOVE_ANIMATION_SPEED
        Animation speed for enemy units.
        See Also:
        Constant Field Values
      • FRIENDLY_MOVE_ANIMATION_SPEED

        public static final java.lang.String FRIENDLY_MOVE_ANIMATION_SPEED
        Animation speed for friendly units.
        See Also:
        Constant Field Values
      • DEFAULT_ZOOM_LEVEL

        public static final java.lang.String DEFAULT_ZOOM_LEVEL
        Default zoom level of the minimap.
        See Also:
        Constant Field Values
      • ALWAYS_CENTER

        public static final java.lang.String ALWAYS_CENTER
        Selected tiles always gets centered if this option is enabled (even if the tile is on screen.
        See Also:
        Constant Field Values
      • JUMP_TO_ACTIVE_UNIT

        public static final java.lang.String JUMP_TO_ACTIVE_UNIT
        If this option is enabled, the display will recenter in order to display the active unit if it is not on screen.
        See Also:
        Constant Field Values
      • MAP_SCROLL_ON_DRAG

        public static final java.lang.String MAP_SCROLL_ON_DRAG
        Option to scroll when dragging units on the mapboard.
        See Also:
        Constant Field Values
      • AUTO_SCROLL

        public static final java.lang.String AUTO_SCROLL
        Option to auto-scroll on mouse movement.
        See Also:
        Constant Field Values
      • DISPLAY_GRID

        public static final java.lang.String DISPLAY_GRID
        Whether to display the grid by default or not.
        See Also:
        Constant Field Values
      • DISPLAY_BORDERS

        public static final java.lang.String DISPLAY_BORDERS
        Whether to display borders by default or not.
        See Also:
        Constant Field Values
      • DISPLAY_FOG_OF_WAR

        public static final java.lang.String DISPLAY_FOG_OF_WAR
        Whether to draw the fog of war on the actual map or not.
        See Also:
        Constant Field Values
      • UNIT_LAST_MOVE_DELAY

        public static final java.lang.String UNIT_LAST_MOVE_DELAY
        Whether to delay on a unit's last move or not.
        See Also:
        Constant Field Values
      • DISPLAY_TILE_TEXT

        public static final java.lang.String DISPLAY_TILE_TEXT
        What text to display in the tiles.
        See Also:
        Constant Field Values
      • DISPLAY_TILE_TEXT_EMPTY

        public static final int DISPLAY_TILE_TEXT_EMPTY
        See Also:
        Constant Field Values
      • DISPLAY_TILE_TEXT_NAMES

        public static final int DISPLAY_TILE_TEXT_NAMES
        See Also:
        Constant Field Values
      • DISPLAY_TILE_TEXT_OWNERS

        public static final int DISPLAY_TILE_TEXT_OWNERS
        See Also:
        Constant Field Values
      • DISPLAY_TILE_TEXT_REGIONS

        public static final int DISPLAY_TILE_TEXT_REGIONS
        See Also:
        Constant Field Values
      • DISPLAY_COLONY_LABELS

        public static final java.lang.String DISPLAY_COLONY_LABELS
        Style of colony labels.
        See Also:
        Constant Field Values
      • MAPCONTROLS_GROUP

        private static final java.lang.String MAPCONTROLS_GROUP
        See Also:
        Constant Field Values
      • DISPLAY_COMPASS_ROSE

        public static final java.lang.String DISPLAY_COMPASS_ROSE
        Whether to display a compass rose or not.
        See Also:
        Constant Field Values
      • DISPLAY_MAP_CONTROLS

        public static final java.lang.String DISPLAY_MAP_CONTROLS
        Whether to display the map controls or not.
        See Also:
        Constant Field Values
      • MAP_CONTROLS

        public static final java.lang.String MAP_CONTROLS
        The type of map controls, corner or classic.
        See Also:
        Constant Field Values
      • MAP_CONTROLS_CORNERS

        public static final java.lang.String MAP_CONTROLS_CORNERS
        Styles of map controls.
        See Also:
        Constant Field Values
      • MAP_CONTROLS_CLASSIC

        public static final java.lang.String MAP_CONTROLS_CLASSIC
        See Also:
        Constant Field Values
      • MINIMAP_TOGGLE_FOG_OF_WAR

        public static final java.lang.String MINIMAP_TOGGLE_FOG_OF_WAR
        Whether to draw the fog of war on the minimap.
        See Also:
        Constant Field Values
      • MINIMAP_TOGGLE_BORDERS

        public static final java.lang.String MINIMAP_TOGGLE_BORDERS
        Whether to draw the borders on the minimap.
        See Also:
        Constant Field Values
      • MINIMAP_BACKGROUND_COLOR

        public static final java.lang.String MINIMAP_BACKGROUND_COLOR
        The color to fill in around the actual map on the minimap. Typically only visible when the minimap is at full zoom-out, but at the default 'black' you can't differentiate between the background and the (unexplored) map. Actually: clientOptions.minimap.color.background
        See Also:
        Constant Field Values
      • MESSAGES_GROUP_BY

        public static final java.lang.String MESSAGES_GROUP_BY
        Used by GUI, this defines the grouping of ModelMessages. Possible values include nothing, type and source.
        See Also:
        MapViewer, ModelMessage, Constant Field Values
      • MESSAGES_GROUP_BY_NOTHING

        public static final int MESSAGES_GROUP_BY_NOTHING
        See Also:
        Constant Field Values
      • MESSAGES_GROUP_BY_SOURCE

        public static final int MESSAGES_GROUP_BY_SOURCE
        See Also:
        Constant Field Values
      • SHOW_GOODS_MOVEMENT

        public static final java.lang.String SHOW_GOODS_MOVEMENT
        Show goods movement messages. Used by followTradeRoute.
        See Also:
        Constant Field Values
      • SHOW_COLONY_WARNINGS

        public static final java.lang.String SHOW_COLONY_WARNINGS
        Show warnings about colony sites.
        See Also:
        Constant Field Values
      • SHOW_PRECOMBAT

        public static final java.lang.String SHOW_PRECOMBAT
        Show the pre-combat dialog?
        See Also:
        Constant Field Values
      • SHOW_NOT_BEST_TILE

        public static final java.lang.String SHOW_NOT_BEST_TILE
        Show warnings about suboptimal colony tile choice.
        See Also:
        Constant Field Values
      • SHOW_REGION_NAMING

        public static final java.lang.String SHOW_REGION_NAMING
        See Also:
        Constant Field Values
      • COLONY_REPORT

        public static final java.lang.String COLONY_REPORT
        Option for selecting the compact colony report.
        See Also:
        Constant Field Values
      • LABOUR_REPORT

        public static final java.lang.String LABOUR_REPORT
        The type of labour report to display.
        See Also:
        Constant Field Values
      • CUSTOM_STOCK

        public static final java.lang.String CUSTOM_STOCK
        The amount of stock the custom house should keep when selling goods.
        See Also:
        Constant Field Values
      • LOW_LEVEL

        public static final java.lang.String LOW_LEVEL
        Generate warning of stock drops below this percentage of capacity.
        See Also:
        Constant Field Values
      • HIGH_LEVEL

        public static final java.lang.String HIGH_LEVEL
        Generate warning of stock exceeds this percentage of capacity.
        See Also:
        Constant Field Values
      • STOCK_ACCOUNTS_FOR_PRODUCTION

        public static final java.lang.String STOCK_ACCOUNTS_FOR_PRODUCTION
        Should trade route units check production to determine goods levels at stops along its route?
        See Also:
        Constant Field Values
      • REMEMBER_PANEL_POSITIONS

        public static final java.lang.String REMEMBER_PANEL_POSITIONS
        Whether to remember the positions of various dialogs and panels.
        See Also:
        Constant Field Values
      • REMEMBER_PANEL_SIZES

        public static final java.lang.String REMEMBER_PANEL_SIZES
        Whether to remember the sizes of various dialogs and panels.
        See Also:
        Constant Field Values
      • DISABLE_GRAY_LAYER

        public static final java.lang.String DISABLE_GRAY_LAYER
        Whether to display end turn grey background or not.
        See Also:
        Constant Field Values
      • AUTOLOAD_EMIGRANTS

        public static final java.lang.String AUTOLOAD_EMIGRANTS
        Option to autoload emigrants on sailing to america.
        See Also:
        Constant Field Values
      • AUTOLOAD_SENTRIES

        public static final java.lang.String AUTOLOAD_SENTRIES
        Option to autoload sentried units.
        See Also:
        Constant Field Values
      • AUTO_END_TURN

        public static final java.lang.String AUTO_END_TURN
        Automatically end the turn when no units can be * made active.
        See Also:
        Constant Field Values
      • SHOW_END_TURN_DIALOG

        public static final java.lang.String SHOW_END_TURN_DIALOG
        Show the end turn dialog.
        See Also:
        Constant Field Values
      • INDIAN_DEMAND_RESPONSE

        public static final java.lang.String INDIAN_DEMAND_RESPONSE
        Set the default native demand action.
        See Also:
        Constant Field Values
      • INDIAN_DEMAND_RESPONSE_ASK

        public static final int INDIAN_DEMAND_RESPONSE_ASK
        See Also:
        Constant Field Values
      • INDIAN_DEMAND_RESPONSE_ACCEPT

        public static final int INDIAN_DEMAND_RESPONSE_ACCEPT
        See Also:
        Constant Field Values
      • INDIAN_DEMAND_RESPONSE_REJECT

        public static final int INDIAN_DEMAND_RESPONSE_REJECT
        See Also:
        Constant Field Values
      • UNLOAD_OVERFLOW_RESPONSE

        public static final java.lang.String UNLOAD_OVERFLOW_RESPONSE
        Set the default warehouse overflow on unload action.
        See Also:
        Constant Field Values
      • UNLOAD_OVERFLOW_RESPONSE_ASK

        public static final int UNLOAD_OVERFLOW_RESPONSE_ASK
        See Also:
        Constant Field Values
      • UNLOAD_OVERFLOW_RESPONSE_NEVER

        public static final int UNLOAD_OVERFLOW_RESPONSE_NEVER
        See Also:
        Constant Field Values
      • UNLOAD_OVERFLOW_RESPONSE_ALWAYS

        public static final int UNLOAD_OVERFLOW_RESPONSE_ALWAYS
        See Also:
        Constant Field Values
      • MIN_NUMBER_FOR_DISPLAYING_GOODS_COUNT

        public static final java.lang.String MIN_NUMBER_FOR_DISPLAYING_GOODS_COUNT
        Used by GUI, the number will be displayed when a group of goods are higher than this number.
        See Also:
        MapViewer, Constant Field Values
      • MAX_NUMBER_OF_GOODS_IMAGES

        public static final java.lang.String MAX_NUMBER_OF_GOODS_IMAGES
        Used by GUI, this is the most repetitions drawn of a goods image for a single goods grouping.
        See Also:
        MapViewer, Constant Field Values
      • MIN_NUMBER_FOR_DISPLAYING_GOODS

        public static final java.lang.String MIN_NUMBER_FOR_DISPLAYING_GOODS
        Used by GUI, this is the minimum number of goods a colony must possess for the goods to show up at the bottom of the colony panel.
        See Also:
        GUI, Constant Field Values
      • COLONY_COMPARATOR

        public static final java.lang.String COLONY_COMPARATOR
        Used by GUI to sort colonies.
        See Also:
        Constant Field Values
      • COLONY_COMPARATOR_POSITION

        public static final int COLONY_COMPARATOR_POSITION
        See Also:
        Constant Field Values
      • SHOW_SAVEGAME_SETTINGS

        public static final java.lang.String SHOW_SAVEGAME_SETTINGS
        Use default values for savegames instead of displaying a dialog.
        See Also:
        Constant Field Values
      • SHOW_SAVEGAME_SETTINGS_NEVER

        public static final int SHOW_SAVEGAME_SETTINGS_NEVER
        See Also:
        Constant Field Values
      • SHOW_SAVEGAME_SETTINGS_MULTIPLAYER

        public static final int SHOW_SAVEGAME_SETTINGS_MULTIPLAYER
        See Also:
        Constant Field Values
      • SHOW_SAVEGAME_SETTINGS_ALWAYS

        public static final int SHOW_SAVEGAME_SETTINGS_ALWAYS
        See Also:
        Constant Field Values
      • AUTOSAVE_PERIOD

        public static final java.lang.String AUTOSAVE_PERIOD
        Option for setting the period of autosaves. The value 0 signals that autosaving is disabled.
        See Also:
        Constant Field Values
      • AUTOSAVE_VALIDITY

        public static final java.lang.String AUTOSAVE_VALIDITY
        Option for setting the number of days autosaves are keep (valid time). If set to 0, valid time is not checked.
        See Also:
        Constant Field Values
      • AUTOSAVE_DELETE

        public static final java.lang.String AUTOSAVE_DELETE
        Option for deleting autosaves when a new game is started. If set to true, old autosaves will be deleted if a new game is started.
        See Also:
        Constant Field Values
      • CONFIRM_SAVE_OVERWRITE

        public static final java.lang.String CONFIRM_SAVE_OVERWRITE
        Whether to display confirmation for the overwrite of existing save files.
        See Also:
        Constant Field Values
      • AUTO_SAVE_PREFIX

        public static final java.lang.String AUTO_SAVE_PREFIX
        Prefix for the auto-save file.
        See Also:
        Constant Field Values
      • LAST_TURN_NAME

        public static final java.lang.String LAST_TURN_NAME
        Stem of the last-turn save file name.
        See Also:
        Constant Field Values
      • BEFORE_LAST_TURN_NAME

        public static final java.lang.String BEFORE_LAST_TURN_NAME
        Stem of the before-last-turn save file name.
        See Also:
        Constant Field Values
      • AUDIO_MIXER

        public static final java.lang.String AUDIO_MIXER
        Choose the default mixer.
        See Also:
        Constant Field Values
      • AUDIO_VOLUME

        public static final java.lang.String AUDIO_VOLUME
        The volume level to set.
        See Also:
        Constant Field Values
      • AUDIO_ALERTS

        public static final java.lang.String AUDIO_ALERTS
        Play an alert sound on message arrival.
        See Also:
        Constant Field Values
      • ETC

        public static final java.lang.String ETC
        The dynamic placement options.
        See Also:
        Constant Field Values
      • specialKeys

        private static final java.util.List<java.lang.String> specialKeys
      • colonyAgeComparator

        private static final java.util.Comparator<Colony> colonyAgeComparator
        Compare by ascending age.
      • colonyNameComparator

        private static java.util.concurrent.atomic.AtomicReference<java.util.Comparator<Colony>> colonyNameComparator
        Compare by name, initialized at run time.
      • colonySizeComparator

        private static final java.util.Comparator<Colony> colonySizeComparator
        Compare by descending size then liberty.
      • colonySoLComparator

        private static final java.util.Comparator<Colony> colonySoLComparator
        Compare by descending liberty then size.
      • colonyPositionComparator

        private static final java.util.Comparator<Colony> colonyPositionComparator
        Compare by position on the map.
      • friendlyMoveAnimationSpeeds

        private static final java.util.Map<java.lang.Integer,​java.lang.String> friendlyMoveAnimationSpeeds
        Friendly move animation speed option values.
    • Constructor Detail

      • ClientOptions

        public ClientOptions()
        Creates a new ClientOptions. Unlike other OptionGroup classes, ClientOptions can not supply a specification as it is needed before the specification is available.
    • Method Detail

      • load

        private boolean load​(FreeColSavegameFile save)
        Loads the options from the given save game.
        Parameters:
        save - The FreeColSaveGame to read the options from.
        Returns:
        True if the options were loaded without error.
      • merge

        public boolean merge​(java.io.File file)
        Merge the options from the given file game.
        Parameters:
        file - The File to merge the options from.
        Returns:
        True if the options were merge without error.
      • merge

        public boolean merge​(FreeColSavegameFile save)
        Merge the options from the given save game.
        Parameters:
        save - The FreeColSaveGame to merge from.
        Returns:
        True if the options were merged without error.
      • getActiveMods

        public java.util.List<FreeColModFile> getActiveMods()
        Gets a list of active mods in this ClientOptions.
        Returns:
        A list of active mods.
      • getDisplayTileText

        public int getDisplayTileText()
        Get the client's preferred tile text type.
        Returns:
        A DISPLAY_TILE_TEXT_ value
      • getColonyComparator

        public java.util.Comparator<Colony> getColonyComparator()
        Get the client's preferred comparator for colonies.
        Returns:
        The current colony Comparator.
      • getColonyComparatorInternal

        private static java.util.Comparator<Colony> getColonyComparatorInternal​(int type)
        Get the colony comparator identified by type.
        Parameters:
        type - The colony comparator option integer value.
        Returns:
        The corresponding colony Comparator.
      • getModelMessageComparator

        public java.util.Comparator<ModelMessage> getModelMessageComparator​(Game game)
        Return the client's preferred comparator for ModelMessages.
        Parameters:
        game - The Game to extract a comparator for.
        Returns:
        The preferred Comparator.
      • fixClientOptions

        public void fixClientOptions()
        Perform backward compatibility fixups on new client options as they are introduced. Annotate with introduction version so we can clean these up as they become standard.
      • addBooleanOption

        private void addBooleanOption​(java.lang.String id,
                                      java.lang.String gr,
                                      boolean val)
      • addIntegerOption

        private void addIntegerOption​(java.lang.String id,
                                      java.lang.String gr,
                                      int val)
      • addOptionGroup

        private void addOptionGroup​(java.lang.String id,
                                    java.lang.String gr)
      • addRangeOption

        private void addRangeOption​(java.lang.String id,
                                    java.lang.String gr,
                                    int rank,
                                    java.util.Map<java.lang.Integer,​java.lang.String> entries)
        Add a new range option.
        Parameters:
        id - The option identifier.
        gr - The group identifier.
        rank - The option rank.
        entries - The options in the range.
      • addTextOption

        private void addTextOption​(java.lang.String id,
                                   java.lang.String gr,
                                   java.lang.String val)
        Add a new text option.
        Parameters:
        id - The option identifier.
        gr - The group identifier.
        val - The the text value.
      • regroup

        private void regroup​(java.lang.String id,
                             java.lang.String gr)
        Move an option to a different group.
        Parameters:
        id - The identifier for the option to move.
        gr - The identifier for the option group to move to.
      • getPanelPosition

        public java.awt.Point getPanelPosition​(java.lang.String className)
        Extract the panel position options for a given panel class name as a point.
        Parameters:
        className - The panel class name.
        Returns:
        A Point for the position if found, else null.
      • getPanelSize

        public java.awt.Dimension getPanelSize​(java.lang.String className)
        Extract the panel size options for a given panel class name as a dimension.
        Parameters:
        className - The panel class name.
        Returns:
        A Dimension for the size if found, else null.
      • getSpecialOptions

        public static java.util.Map<java.lang.String,​java.lang.String> getSpecialOptions()
                                                                                        throws FreeColException
        Extracts the special options from the client options file. Note: called early, the logger is not yet reliably available.
        Returns:
        A map of the special options and the values found for them.
        Throws:
        FreeColException - if there is a problem reading the stream.
      • getXMLTagName

        public java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Overrides:
        getXMLTagName in class OptionGroup
        Returns:
        The tag.