22 package com.realtime.crossfire.jxclient.skin.skin;
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.HashSet;
39 import java.util.Iterator;
40 import org.jetbrains.annotations.NotNull;
41 import org.jetbrains.annotations.Nullable;
81 private final Collection<CommandList>
initEvents =
new ArrayList<>();
93 private final Collection<GUIElement>
guiElements =
new HashSet<>();
99 private final Collection<SkinEvent>
skinEvents =
new HashSet<>();
166 if (minResolution.getWidth() > maxResolution.getWidth()) {
167 throw new IllegalArgumentException(
"minimum width must not exceed maximum width");
169 if (minResolution.getHeight() > maxResolution.getHeight()) {
170 throw new IllegalArgumentException(
"minimum height must not exceed maximum height");
244 final AssertionError error =
new AssertionError(
"keybind dialog does not exist");
259 final AssertionError error =
new AssertionError(
"query dialog does not exist");
274 final AssertionError error =
new AssertionError(
"book dialog does not exist");
289 final AssertionError error =
new AssertionError(
"main dialog does not exist");
304 final AssertionError error =
new AssertionError(
"meta dialog does not exist");
319 final AssertionError error =
new AssertionError(
"start dialog does not exist");
331 return dialogs.
lookup(name);
349 return definedCommandLists.
lookup(name);
367 if (this.tooltipManager != null) {
368 throw new IllegalStateException(
"skin is already attached");
383 tooltipManager = null;
384 if (tmpTooltipManager != null) {
388 optionNames.forEach(optionManager::removeOption);
400 final int newScreenWidth = Math.max(minResolution.
getWidth(), Math.min(maxResolution.
getWidth(), screenWidth));
401 final int newScreenHeight = Math.max(minResolution.
getHeight(), Math.min(maxResolution.
getHeight(), screenHeight));
402 if (currentScreenWidth == newScreenWidth && currentScreenHeight == newScreenHeight) {
405 currentScreenWidth = newScreenWidth;
406 currentScreenHeight = newScreenHeight;
414 guiElements.add(guiElement);
421 public void addDialog(@NotNull
final String dialogName) {
442 definedCommandLists.
insert(commandListName, commandList);
450 initEvents.add(commandList);
462 optionManager.
addOption(optionName, documentation, commandCheckBoxOption);
466 optionNames.add(optionName);
491 skinEvents.add(skinEvent);
String getDialogToLoad()
Returns one dialog pending loading.
final Collection< CommandList > initEvents
All "event init" commands in execution order.
The base class for all options.
Abstract base class for all label classes.
void attach(@NotNull final TooltipManagerImpl tooltipManager)
Attaches this skin to a gui manager.the tooltip manager to attach to
Combines a list of GUIElements to for a gui.
Gui getMetaInterface()
Returns the server selection window.the dialog
Interface for events attached to skins.
final Collection< String > optionNames
The defined option names.
void dispose()
Releases all allocated resources.
Resolution minResolution
The minimal resolution.
void addDialog(@NotNull final String dialogName)
Defines a new dialog.
String getSkinName()
Returns a short name for the skin.It is used to construct path or file names. the skin name ...
void insertGuiElement(@NotNull final GUIElement guiElement)
Adds a new GUIElement to this skin.
void setSkinName(@NotNull final String skinName, @NotNull final Resolution minResolution, @NotNull final Resolution maxResolution)
Sets the skin name.
void addOption(@NotNull final String optionName, @NotNull final String documentation, @NotNull final Option commandCheckBoxOption)
Add a new option.
Gui addDialog(@NotNull final String name)
Creates a new dialog instance.
void setTooltipLabel(@Nullable final AbstractLabel tooltipLabel)
Sets the AbstractLabel that is used to display tooltips.
final OptionManager optionManager
The OptionManager to use.
void addCommandList(@NotNull final String commandListName, @NotNull final CommandListType commandListType)
Defines a new command list.
Maintains a set of named options.
TooltipManagerImpl tooltipManager
The TooltipManagerImpl currently attached to or.
void addOption(@NotNull final String optionName, @NotNull final String documentation, @NotNull final Option option)
Adds a new option.
void detach()
Frees all allocated resources.
final KeyBindings defaultKeyBindings
The default key bindings.
Gui getDialogQuery()
Returns the dialog for query text input.the dialog
int getWidth()
Returns the width in pixels.
final JXCSkinCache< CommandList > definedCommandLists
All defined command lists.
Gui getDialogQuit()
Returns the "really quit?" dialog.It is opened when the user presses ESCAPE. the dialog ornull if th...
final Collection< SkinEvent > skinEvents
All SkinEvents attached to this instance.
Defines a JXClient skin consisting of a main Gui and zero or more dialog Guis.
Gui getDialogDisconnect()
Returns the "disconnect from server?" dialog.It is opened when the user presses ESCAPE. the dialog ornull if the dialog does not exist
int getHeight()
Returns the height in pixels.
CommandList getCommandList(@NotNull final String name)
Returns a named command list.the name of the command list the command list if the command list does n...
Interface defining an abstract GUI element.
Gui getDialogBook(final int bookNo)
Returns the popup dialog for readables.the book ID the dialog
Gui lookup(@NotNull final String name)
Returns a dialog instance by dialog name.
Resolution maxResolution
The maximal resolution.
void insert(@NotNull final String name, @NotNull final T t)
Adds a new element to the cache.
Iterator< Gui > iterator()
Returns all gui instances of this skin.The instances has no defined order. an iterator returning all ...
int currentScreenHeight
The current screen height.
Iterator< Gui > iterator()
Indicates about an incorrect option.
final Collection< GUIElement > guiElements
All GUI elements.
void addInitEvent(@NotNull final CommandList commandList)
Adds a command list to be executed on "init" events.
Resolution getMaxResolution()
Returns the maximal resolution of this skin.the maximal resolution
KeyBindings getDefaultKeyBindings()
Returns the default key bindings for this skin.the default key bindings
Default JXCSkin implementation.
String getDialogToLoad()
Returns one dialog pending loading.
void setScreenSize(final int screenWidth, final int screenHeight)
Updates the skin's gui elements to a screen size.the new screen width the new screen height ...
Implements a cache for elements identified by name.
Exception thrown if a skin related problem occurs.
DefaultJXCSkin(@NotNull final KeyBindings defaultKeyBindings, @NotNull final OptionManager optionManager, @NotNull final Dialogs dialogs)
Creates a new instance.
Gui getStartInterface()
Returns the start window.the dialog
void addSkinEvent(@NotNull final SkinEvent skinEvent)
Records a SkinEvent attached to this instance.
Information about JXClient's screen/window resolution.
A list of GUICommand instances.
AbstractLabel tooltipLabel
The tooltip label or.
Gui getDialogKeyBind()
Returns the key bindings dialog.the dialog
void dispose()
Will be called when the skin is disposed.
AbstractLabel getTooltipLabel()
Returns the AbstractLabel that is used to display tooltips.the label ornull if tooltips are disabled...
Manages a set of key bindings.
void execute()
Execute the command list by calling GUICommand#execute() for each command in order.
String skinName
The skin name.
Maintains a set of Gui instances representing dialog windows.
T lookup(@NotNull final String name)
Looks up an element by name.
final Dialogs dialogs
All defined dialogs.
Resolution getMinResolution()
Returns the minimal resolution of this skin.the minimal resolution
int currentScreenWidth
The current screen width.
Gui getDialogConnect()
Returns the "connection in progress" dialog.It is opened while the connection establishment is in pro...
Gui getDialog(@NotNull final String name)
Returns a dialog by name.the dialog's name the dialog if the dialog does not exist ...
Gui getMainInterface()
Returns the main window.the dialog