22 package com.realtime.crossfire.jxclient.skin.io;
146 import java.awt.Color;
147 import java.awt.Component;
148 import java.awt.Container;
149 import java.awt.Font;
150 import java.awt.Image;
151 import java.awt.image.BufferedImage;
152 import java.io.IOException;
153 import java.io.InputStream;
154 import java.io.InputStreamReader;
155 import java.io.LineNumberReader;
156 import java.util.ArrayList;
157 import java.util.Collection;
158 import java.util.Comparator;
159 import java.util.Iterator;
160 import java.util.List;
161 import java.util.TreeSet;
162 import javax.swing.GroupLayout;
163 import javax.swing.GroupLayout.Group;
164 import javax.swing.GroupLayout.SequentialGroup;
165 import javax.swing.SwingConstants;
166 import org.jetbrains.annotations.NotNull;
167 import org.jetbrains.annotations.Nullable;
406 final Comparable<String> n1 = o1.getName();
407 final String n2 = o2.getName();
408 return n1.compareTo(n2);
438 public JXCSkinLoader(@NotNull
final Model model, @NotNull
final ItemView inventoryView, @NotNull
final FloorView floorView, @NotNull
final SpellsView spellView, @NotNull
final SpellSkillView spellSkillsView, @NotNull
final FacesManager facesManager, @NotNull
final MapUpdaterState mapUpdaterState, @NotNull
final KeyBindings defaultKeyBindings, @NotNull
final OptionManager optionManager,
final int defaultTileSize, @NotNull
final KeybindingsManager keybindingsManager, @NotNull
final QuestsView questView, @NotNull
final CommandHistoryFactory commandHistoryFactory, @NotNull
final KnowledgeView knowledgeView, @NotNull
final KnowledgeTypeView knowledgeTypeView,
final boolean avoidCopyArea, @NotNull
final GuiManager guiManager) {
481 public JXCSkin load(@NotNull
final JXCSkinSource skinSource, @NotNull
final CrossfireServerConnection crossfireServerConnection, @NotNull
final GuiStateManager guiStateManager, @NotNull
final TooltipManager tooltipManager, @NotNull
final JXCWindowRenderer windowRenderer, @NotNull
final GUIElementListener elementListener, @NotNull
final MetaserverModel metaserverModel, @NotNull
final CharacterModel characterModel, @NotNull
final CommandQueue commandQueue, @NotNull
final Shortcuts shortcuts, @NotNull
final CommandExecutor commandExecutor, @NotNull
final CurrentSpellManager currentSpellManager, @NotNull
final CommandCallback commandCallback, @NotNull
final Macros macros, @NotNull
final GuiFactory guiFactory, @NotNull
final SmoothFaces smoothFaces)
throws JXCSkinException {
485 final Image nextGroupFace;
488 }
catch (
final IOException ex) {
491 final Image prevGroupFace;
494 }
catch (
final IOException ex) {
500 commandParser =
new CommandParser(dialogs, floorView, definedGUIElements);
501 skin =
new DefaultJXCSkin(defaultKeyBindings, optionManager, dialogs);
517 definedFonts.
clear();
518 textButtonFactory = null;
519 dialogFactory = null;
520 checkBoxFactory = null;
522 load(skinSource,
"global", crossfireServerConnection, guiStateManager, tooltipManager, windowRenderer, elementListener, metaserverModel, characterModel, commandQueue, null, shortcuts, commandExecutor, currentSpellManager, commandCallback, macros, nextGroupFace, prevGroupFace, smoothFaces);
529 load(skinSource, name, crossfireServerConnection, guiStateManager, tooltipManager, windowRenderer, elementListener, metaserverModel, characterModel, commandQueue, gui, shortcuts, commandExecutor, currentSpellManager, commandCallback, macros, nextGroupFace, prevGroupFace, smoothFaces);
532 definedFonts.
clear();
533 textButtonFactory = null;
534 dialogFactory = null;
535 checkBoxFactory = null;
541 if (skinToDetach != null) {
542 skinToDetach.detach();
543 windowRenderer.setTooltip(null);
573 private void load(@NotNull
final JXCSkinSource skinSource, @NotNull
final String dialogName, @NotNull
final CrossfireServerConnection server, @NotNull
final GuiStateManager guiStateManager, @NotNull
final TooltipManager tooltipManager, @NotNull
final JXCWindowRenderer windowRenderer, @NotNull
final GUIElementListener elementListener, @NotNull
final MetaserverModel metaserverModel, @NotNull
final CharacterModel characterModel, @NotNull
final CommandQueue commandQueue, @Nullable
final Gui gui, @NotNull
final Shortcuts shortcuts, @NotNull
final CommandExecutor commandExecutor, @NotNull
final CurrentSpellManager currentSpellManager, @NotNull
final CommandCallback commandCallback, @NotNull
final Macros macros, @NotNull
final Image nextGroupFace, @NotNull
final Image prevGroupFace, @NotNull
final SmoothFaces smoothFaces)
throws JXCSkinException {
574 String resourceName = dialogName+
".skin";
576 definedGUIElements.
clear();
578 InputStream inputStream;
580 inputStream = skinSource.getInputStream(resourceName);
581 }
catch (
final IOException ignored) {
582 resourceName = dialogName+
".skin";
583 inputStream = skinSource.getInputStream(resourceName);
586 load(skinSource, dialogName, resourceName, inputStream, server, guiStateManager, tooltipManager, windowRenderer, elementListener, metaserverModel, characterModel, commandQueue, gui, shortcuts, commandExecutor, currentSpellManager, commandCallback, macros, nextGroupFace, prevGroupFace, smoothFaces);
591 throw new JXCSkinException(skinSource.getURI(resourceName)+
": "+ex.getMessage(), ex);
593 definedGUIElements.
clear();
623 private void load(@NotNull
final JXCSkinSource skinSource, @NotNull
final String dialogName, @NotNull
final String resourceName, @NotNull
final InputStream inputStream, @NotNull
final CrossfireServerConnection server, @NotNull
final GuiStateManager guiStateManager, @NotNull
final TooltipManager tooltipManager, @NotNull
final JXCWindowRenderer windowRenderer, @NotNull
final GUIElementListener elementListener, @NotNull
final MetaserverModel metaserverModel, @NotNull
final CharacterModel characterModel, @NotNull
final CommandQueue commandQueue, @Nullable
final Gui gui, @NotNull
final Shortcuts shortcuts, @NotNull
final CommandExecutor commandExecutor, @NotNull
final CurrentSpellManager currentSpellManager, @NotNull
final CommandCallback commandCallback, @NotNull
final Macros macros, @NotNull
final Image nextGroupFace, @NotNull
final Image prevGroupFace, @NotNull
final SmoothFaces smoothFaces)
throws JXCSkinException {
625 try (
final InputStreamReader isr =
new InputStreamReader(inputStream,
"UTF-8")) {
626 final LineNumberReader lnr =
new LineNumberReader(isr);
628 boolean isDialog =
false;
630 final String line = lnr.readLine();
635 if (line.startsWith(
"#") || line.isEmpty()) {
639 final String[] argsTmp;
645 final Args args =
new Args(argsTmp);
646 final String cmd = args.get();
647 if (gui != null && cmd.equals(
"button")) {
648 parseButton(args, tooltipManager, elementListener, lnr);
649 }
else if (gui != null && cmd.equals(
"checkbox")) {
651 }
else if (gui != null && cmd.equals(
"combobox")) {
653 }
else if (cmd.equals(
"commandlist")) {
654 parseCommandList(args, guiStateManager, lnr, commandExecutor, commandQueue, server, commandCallback, macros);
655 }
else if (cmd.equals(
"commandlist_add")) {
656 parseCommandListAdd(args, guiStateManager, lnr, commandExecutor, commandQueue, server, commandCallback, macros);
657 }
else if (gui != null && cmd.equals(
"command_text")) {
658 parseCommandText(args, commandCallback, tooltipManager, elementListener, commandExecutor);
659 }
else if (cmd.equals(
"def")) {
661 }
else if (gui != null && cmd.equals(
"dialog")) {
663 throw new JXCSkinException(
"'dialog' must not be used more than once per dialog");
665 parseDialog(args, tooltipManager, windowRenderer, elementListener, lnr, gui, dialogName);
667 }
else if (gui != null && cmd.equals(
"dialog_hide")) {
669 }
else if (gui != null && cmd.equals(
"dupgauge")) {
671 }
else if (gui != null && cmd.equals(
"duptextgauge")) {
673 }
else if (cmd.equals(
"event")) {
675 }
else if (gui != null && cmd.equals(
"fill")) {
676 parseFill(args, tooltipManager, elementListener);
677 }
else if (cmd.equals(
"font")) {
679 }
else if (gui != null && cmd.equals(
"gauge")) {
680 parseGauge(args, tooltipManager, elementListener, lnr);
681 }
else if (gui != null && cmd.equals(
"ignore")) {
683 }
else if (gui != null && cmd.equals(
"inventory_list")) {
684 parseList(args,
ListType.
INVENTORY, tooltipManager, elementListener, commandQueue, server, currentSpellManager, nextGroupFace, prevGroupFace);
685 }
else if (gui != null && cmd.equals(
"floor_list")) {
686 parseList(args,
ListType.
GROUND, tooltipManager, elementListener, commandQueue, server, currentSpellManager, nextGroupFace, prevGroupFace);
687 }
else if (gui != null && cmd.equals(
"spells_list")) {
688 parseList(args,
ListType.
SPELL, tooltipManager, elementListener, commandQueue, server, currentSpellManager, nextGroupFace, prevGroupFace);
689 }
else if (gui != null && cmd.equals(
"spell_skills")) {
690 parseList(args,
ListType.
SPELL_SKILLS, tooltipManager, elementListener, commandQueue, server, currentSpellManager, nextGroupFace, prevGroupFace);
691 }
else if (gui != null && cmd.equals(
"quests_list")) {
692 parseList(args,
ListType.
QUEST, tooltipManager, elementListener, commandQueue, server, currentSpellManager, nextGroupFace, prevGroupFace);
693 }
else if (gui != null && cmd.equals(
"knowledge_types")) {
695 }
else if (gui != null && cmd.equals(
"knowledge_list")) {
697 }
else if (gui != null && cmd.equals(
"horizontal")) {
699 }
else if (gui != null && cmd.equals(
"item")) {
700 parseItem(args, tooltipManager, elementListener, commandQueue, server, shortcuts, currentSpellManager, nextGroupFace, prevGroupFace);
701 }
else if (cmd.equals(
"key")) {
703 }
else if (gui != null && cmd.equals(
"label_html")) {
705 }
else if (gui != null && cmd.equals(
"label_multi")) {
707 }
else if (gui != null && cmd.equals(
"label_query")) {
709 }
else if (gui != null && cmd.equals(
"label_failure")) {
711 }
else if (gui != null && cmd.equals(
"label_message")) {
712 parseLabelMessage(args, tooltipManager, elementListener, server, windowRenderer);
713 }
else if (gui != null && cmd.equals(
"label_text")) {
715 }
else if (gui != null && cmd.equals(
"label_stat")) {
717 }
else if (gui != null && cmd.equals(
"label_stat2")) {
719 }
else if (gui != null && cmd.equals(
"label_spell")) {
720 parseLabelSpell(args, tooltipManager, elementListener, currentSpellManager);
721 }
else if (gui != null && cmd.equals(
"link_size")) {
723 }
else if (gui != null && cmd.equals(
"log_label")) {
725 }
else if (gui != null && cmd.equals(
"log_message")) {
727 }
else if (gui != null && cmd.equals(
"log_color")) {
729 }
else if (gui != null && cmd.equals(
"log_filter")) {
731 }
else if (gui != null && cmd.equals(
"minimap")) {
733 }
else if (gui != null && cmd.equals(
"map")) {
734 parseMap(args, tooltipManager, elementListener, server, smoothFaces);
735 }
else if (gui != null && cmd.equals(
"meta_list")) {
736 parseMetaList(args, tooltipManager, elementListener, metaserverModel);
737 }
else if (gui != null && cmd.equals(
"picture")) {
739 }
else if (gui != null && cmd.equals(
"query_text")) {
740 parseQueryText(args, server, commandCallback, tooltipManager, elementListener);
741 }
else if (gui != null && cmd.equals(
"set_forced_active")) {
743 }
else if (gui != null && cmd.equals(
"set_auto_size")) {
745 }
else if (gui != null && cmd.equals(
"set_default")) {
747 }
else if (gui != null && cmd.equals(
"set_invisible")) {
749 }
else if (gui != null && cmd.equals(
"set_modal")) {
751 }
else if (gui != null && cmd.equals(
"scrollbar")) {
753 }
else if (gui == null && cmd.equals(
"skin_name")) {
755 }
else if (gui != null && cmd.equals(
"text")) {
756 parseText(args, commandCallback, tooltipManager, elementListener);
757 }
else if (gui != null && cmd.equals(
"textbutton")) {
759 }
else if (gui != null && cmd.equals(
"textgauge")) {
761 }
else if (cmd.equals(
"tooltip")) {
763 }
else if (cmd.equals(
"vertical")) {
765 }
else if (cmd.equals(
"character_list")) {
767 }
else if (cmd.equals(
"hide_input")) {
770 throw new IOException(
"unknown keyword '"+cmd+
"'");
773 if (args.hasMore()) {
774 throw new IOException(
"excess arguments");
778 throw new IOException(ex.getMessage()+
" in line "+lnr.getLineNumber(), ex);
779 }
catch (
final IllegalArgumentException ex) {
780 final Object msg = ex.getMessage();
781 throw new IOException(
"invalid parameter"+(msg == null ?
"" :
" ("+msg+
")")+
" in line "+lnr.getLineNumber(), ex);
786 }
catch (
final IOException ex) {
787 throw new JXCSkinException(skinSource.getURI(resourceName)+
": "+ex.getMessage(), ex);
790 final Iterator<AbstractGUIElement> it = definedGUIElements.
iterator();
792 assert !it.hasNext();
817 final String name = args.get();
818 final BufferedImage upImage = imageParser.
getImage(args.get());
819 final BufferedImage downImage = imageParser.
getImage(args.get());
822 @Nullable
final String label;
823 @Nullable
final Font font;
824 @Nullable
final Color color;
827 if (args.hasMore()) {
828 font = definedFonts.
lookup(args.get());
840 insertGuiElement(
new GUIButton(tooltipManager, elementListener, name, upImage, downImage, label, font, color, textX, textY, autoRepeat, commandList));
853 if (checkBoxFactory == null) {
854 throw new IOException(
"missing 'def checkbox' command");
857 final String name = args.get();
860 assert checkBoxFactory != null;
873 final String name = args.get();
874 final String type = args.get();
879 element =
new GUIClassesComboBox(tooltipManager, elementListener, name, model, label);
883 element =
new GUIRacesComboBox(tooltipManager, elementListener, name, model, label);
887 throw new IOException(
"undefined 'combobox' type '"+type+
"'");
906 final String commandListName = args.get();
909 if (args.hasMore()) {
911 addCommand(commandListName, args, element, args.get(), guiStateManager, commandExecutor, lnr, commandQueue, server, commandCallback, macros);
929 final String name = args.get();
931 addCommand(name, args, element, args.get(), guiStateManager, commandExecutor, lnr, commandQueue, server, commandCallback, macros);
945 final String name = args.get();
946 final Image activeImage = imageParser.
getImage(args.get());
947 final Image inactiveImage = imageParser.
getImage(args.get());
948 final Font font = definedFonts.
lookup(args.get());
954 insertGuiElement(
new GUICommandText(commandCallback, commandHistory, tooltipManager, elementListener, name, activeImage, inactiveImage, font, inactiveColor, activeColor, margin,
"", commandExecutor));
965 final String type = args.get();
968 final BufferedImage checkedImage = imageParser.
getImage(args.get());
969 final BufferedImage uncheckedImage = imageParser.
getImage(args.get());
970 final Font font = definedFonts.
lookup(args.get());
972 checkBoxFactory =
new CheckBoxFactory(checkedImage, uncheckedImage, font, color);
976 case "checkbox_option":
977 final String optionName = args.get();
985 final String frame = args.get();
986 final Image frameNW = imageParser.
getImage(frame+
"_nw");
987 final Image frameN = imageParser.
getImage(frame+
"_n");
988 final Image frameNE = imageParser.
getImage(frame+
"_ne");
989 final Image frameW = imageParser.
getImage(frame+
"_w");
990 final Image frameC = imageParser.
getImage(frame+
"_c");
991 final Image frameE = imageParser.
getImage(frame+
"_e");
992 final Image frameSW = imageParser.
getImage(frame+
"_sw");
993 final Image frameS = imageParser.
getImage(frame+
"_s");
994 final Image frameSE = imageParser.
getImage(frame+
"_se");
995 final Font titleFont = definedFonts.
lookup(args.get());
999 if (alpha < 0 || alpha > 1.0F) {
1000 throw new IOException(
"invalid alpha value: "+alpha);
1002 dialogFactory =
new DialogFactory(frameNW, frameN, frameNE, frameW, frameC, frameE, frameSW, frameS, frameSE, titleFont, titleColor, titleBackgroundColor, alpha);
1007 final Image cursedImage = imageParser.
getImage(cursedColor, args.getPrev());
1009 final Image damnedImage = imageParser.
getImage(damnedColor, args.getPrev());
1011 final Image magicImage = imageParser.
getImage(magicColor, args.getPrev());
1013 final Image blessedImage = imageParser.
getImage(blessedColor, args.getPrev());
1015 final Image appliedImage = imageParser.
getImage(appliedColor, args.getPrev());
1017 final Image unidentifiedImage = imageParser.
getImage(unidentifiedColor, args.getPrev());
1019 final Image selectorImage = imageParser.
getImage(selectorColor, args.getPrev());
1021 final Image lockedImage = imageParser.
getImage(lockedColor, args.getPrev());
1023 final Image unpaidImage = imageParser.
getImage(unpaidColor, args.getPrev());
1024 final Font font = definedFonts.
lookup(args.get());
1026 defaultItemPainter =
new ItemPainter(cursedImage, damnedImage, magicImage, blessedImage, appliedImage, unidentifiedImage, selectorImage, lockedImage, unpaidImage, cursedColor, damnedColor, magicColor, blessedColor, appliedColor, unidentifiedColor, selectorColor, lockedColor, unpaidColor, font, nrofColor);
1031 final String up = args.get();
1032 final String down = args.get();
1033 final Font font = definedFonts.
lookup(args.get());
1038 textButtonFactory =
new TextButtonFactory(upImages, downImages, font, color, colorSelected);
1042 throw new IOException(
"unknown type '"+type+
"'");
1059 if (dialogFactory == null) {
1060 throw new IOException(
"missing 'def dialog' command");
1067 assert dialogFactory != null;
1068 final Iterable<AbstractGUIElement> elements = dialogFactory.
newDialog(tooltipManager, windowRenderer, elementListener, title);
1072 gui.setName(dialogName);
1073 gui.setDefaultPosition(defaultX, defaultY);
1075 gui.setSaveDialog();
1088 }
while (args.hasMore());
1101 final String name = args.get();
1102 final Image positiveDivImage = imageParser.
getImage(args.get());
1103 final Image positiveModImage = imageParser.
getImage(args.get());
1104 final Image emptyImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1110 final GUIDupGauge element =
new GUIDupGauge(tooltipManager, elementListener, name, positiveDivImage, positiveModImage, emptyImage, orientationDiv, orientationMod, tooltipPrefix.isEmpty() ? null : tooltipPrefix, commandList);
1125 final String name = args.get();
1126 final Image positiveDivImage = imageParser.
getImage(args.get());
1127 final Image positiveModImage = imageParser.
getImage(args.get());
1128 final Image emptyImage = imageParser.
getImage(args.get());
1133 final Font font = definedFonts.
lookup(args.get());
1136 final GUIDupTextGauge element =
new GUIDupTextGauge(tooltipManager, elementListener, name, positiveDivImage, positiveModImage, emptyImage, orientationDiv, orientationMod, tooltipPrefix.isEmpty() ? null : tooltipPrefix, color, font, commandList);
1150 final String type = args.get();
1187 final String subtype = args.get();
1200 throw new IOException(
"undefined event sub-type: "+subtype);
1205 throw new IOException(
"undefined event type: "+type);
1218 final String name = args.get();
1221 if (alpha < 0 || alpha > 1.0F) {
1222 throw new IOException(
"invalid alpha value: "+alpha);
1234 final String name = args.get();
1235 final Font fontNormal = fontParser.
getFont(args.get());
1237 definedFonts.
insert(name, font);
1250 if (dialogFactory == null) {
1251 throw new IOException(
"missing 'def dialog' command");
1254 final String name = args.get();
1255 final Image positiveImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1256 final Image negativeImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1257 final Image emptyImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1262 assert dialogFactory != null;
1264 final GUIGauge element =
new GUIGauge(tooltipManager, elementListener, name, positiveImage, negativeImage, emptyImage, orientation, tooltipPrefix.isEmpty() ? null : tooltipPrefix, alpha, commandList);
1276 final String name = args.get();
1277 definedGUIElements.
lookup(name).setIgnore();
1296 if (defaultItemPainter == null) {
1297 throw new IOException(
"cannot use '"+type+
"_list"+
"' without 'def item' command");
1300 final String name = args.get();
1305 assert defaultItemPainter != null;
1310 element =
new GUIInventoryList(tooltipManager, elementListener, name, cellWidth, cellHeight, inventoryView, selectedItem, commandQueue, itemPainter, server, facesManager, floorView);
1314 element =
new GUIFloorList(tooltipManager, elementListener, name, cellWidth, cellHeight, floorView, selectedItem, commandQueue, itemPainter, server, facesManager, model.
getItemSet(), nextGroupFace, prevGroupFace);
1318 element =
new GUISpellList(tooltipManager, elementListener, name, cellWidth, cellHeight, spellView, selectedItem, model.
getSpellsManager(),
keybindingsManager, commandQueue, itemPainter,
facesManager, currentSpellManager);
1327 element =
new GUISpellSkillList(tooltipManager, elementListener, name, cellWidth, cellHeight, spellSkillsView, selectedItem, model.
getSpellsManager(), itemPainter,
facesManager, defaultSkillIcon);
1330 case KNOWLEDGE_TYPES:
1334 case KNOWLEDGE_LIST:
1335 element =
new GUIKnowledgeList(tooltipManager, elementListener, name, cellWidth, cellHeight, knowledgeView, selectedItem, itemPainter, facesManager, model.
getKnowledgeManager(), commandQueue);
1339 throw new AssertionError(
"unhandled type "+type);
1355 final GroupLayout layout = (GroupLayout)gui.getLayout();
1356 final String begin = args.get();
1357 if (!begin.equals(
"begin")) {
1358 throw new IOException(
"syntax error: expecting 'begin'");
1360 final Collection<GUIElement> unreferencedElements =
new TreeSet<>(
ELEMENT_COMPARATOR);
1361 for (
final GUIElement element : definedGUIElements) {
1362 unreferencedElements.add(element);
1365 final Group content =
parseBegin(args, layout, lnr, unreferencedElements);
1366 if (!unreferencedElements.isEmpty()) {
1367 throw new IOException(
"layout doesn't define elements "+unreferencedElements);
1369 layout.setHorizontalGroup(content);
1373 if (background == null) {
1374 throw new AssertionError(
"element 'dialog_background' is missing");
1376 final Group content =
parseBegin(args, layout, lnr, unreferencedElements);
1379 final Group group2 = layout.createSequentialGroup();
1380 group2.addGap(DIALOG_BORDER_WIDTH);
1381 if (title == null) {
1382 if (close == null) {
1383 final Group group3 = layout.createParallelGroup();
1384 group3.addGroup(content);
1385 group2.addGroup(group3);
1387 final Group group3 = layout.createParallelGroup();
1388 group3.addGap(0, 0, Short.MAX_VALUE);
1389 group3.addComponent(close);
1390 group2.addGroup(group3);
1391 group2.addGroup(content);
1394 final Group group3 = layout.createParallelGroup();
1395 if (close == null) {
1396 group3.addComponent(title);
1397 group3.addGroup(content);
1399 final Group group4 = layout.createSequentialGroup();
1400 group4.addComponent(title);
1401 group4.addComponent(close);
1402 group3.addGroup(group4);
1403 group3.addGroup(content);
1405 group2.addGroup(group3);
1407 group2.addGap(DIALOG_BORDER_WIDTH);
1408 if (!unreferencedElements.isEmpty()) {
1409 throw new IOException(
"layout doesn't define elements "+unreferencedElements);
1412 final Group group1 = layout.createParallelGroup();
1413 group1.addGroup(group2);
1414 group1.addComponent(background);
1416 layout.setHorizontalGroup(group1);
1426 private Component
getUnreferencedElement(@NotNull
final String name, @NotNull
final Collection<GUIElement> unreferencedElements) {
1428 if (component == null) {
1432 return unreferencedElements.remove(component) ? component : null;
1450 final String type = args.get();
1451 final String name = args.get();
1456 if (defaultItemPainter == null) {
1457 throw new IOException(
"cannot use 'item floor' without 'def item' command");
1461 element =
new GUIItemFloor(tooltipManager, elementListener, commandQueue, name, itemPainter, index, server, floorView, model.
getItemSet(),
facesManager, nextGroupFace, prevGroupFace, 0);
1466 if (defaultItemPainter == null) {
1467 throw new IOException(
"cannot use 'item inventory' without 'def item' command");
1471 element =
new GUIItemInventory(tooltipManager, elementListener, commandQueue, name, itemPainter, index, server, facesManager, floorView, inventoryView, 0);
1477 final Image castImage = imageParser.
getImage(castColor, args.getPrev());
1479 final Image invokeImage = imageParser.
getImage(invokeColor, args.getPrev());
1480 final Font font = definedFonts.
lookup(args.get());
1481 element =
new GUIItemShortcut(tooltipManager, elementListener, name, castColor, castImage, invokeColor, invokeImage, index, facesManager, shortcuts, font, currentSpellManager);
1485 if (defaultItemPainter == null) {
1486 throw new IOException(
"cannot use 'item spelllist' without 'def item' command");
1490 element =
new GUIItemSpell(tooltipManager, elementListener, commandQueue, name, itemPainter, index, facesManager, model.
getSpellsManager(), currentSpellManager,
spellView, 0);
1494 throw new IOException(
"undefined item type: "+type);
1506 private void parseKey(@NotNull
final Args args, @Nullable
final Gui gui, @NotNull
final String line)
throws IOException {
1511 throw new IOException(
"invalid key binding: "+ex.getMessage(), ex);
1515 while (args.hasMore()) {
1530 final String name = args.get();
1531 final Font font = definedFonts.
lookup(args.get());
1547 final String name = args.get();
1548 final Font font = definedFonts.
lookup(args.get());
1564 final String name = args.get();
1565 final Font font = definedFonts.
lookup(args.get());
1582 final String name = args.get();
1583 final Font font = definedFonts.
lookup(args.get());
1599 final String name = args.get();
1600 final Font font = definedFonts.
lookup(args.get());
1616 final String name = args.get();
1617 final Font font = definedFonts.
lookup(args.get());
1632 final String name = args.get();
1633 final Font font = definedFonts.
lookup(args.get());
1650 final String name = args.get();
1651 final Font font = definedFonts.
lookup(args.get());
1662 final AbstractGUIElement element =
new GUILabelStats2(tooltipManager, elementListener, name, font, colorNormal, colorUpgradable, colorDepleted, colorBoosted, colorBoostedUpgradable, null, statCurrent, statBase, statRace, statApplied, alignment, model.
getStats());
1676 final String name = args.get();
1677 final Font font = definedFonts.
lookup(args.get());
1691 final String type = args.get();
1692 final List<Component> elements =
new ArrayList<>();
1693 while (args.hasMore()) {
1694 elements.add(definedGUIElements.
lookup(args.get()));
1696 if (elements.size() < 2) {
1697 throw new IOException(
"'link_size' needs at least two gui elements");
1699 final Component[] array = elements.toArray(
new Component[elements.size()]);
1700 final GroupLayout layout = (GroupLayout)gui.getLayout();
1703 layout.linkSize(SwingConstants.HORIZONTAL, array);
1707 layout.linkSize(SwingConstants.VERTICAL, array);
1711 layout.linkSize(SwingConstants.HORIZONTAL, array);
1712 layout.linkSize(SwingConstants.VERTICAL, array);
1716 throw new IOException(
"undefined type '"+type+
"'");
1729 final String name = args.get();
1730 final Image backgroundImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1731 final Font fontPrint = definedFonts.
lookup(args.get());
1732 final Font fontFixed = definedFonts.
lookup(args.get());
1733 final Font fontFixedBold = definedFonts.
lookup(args.get());
1734 final Font fontArcane = definedFonts.
lookup(args.get());
1736 final Fonts fonts =
new Fonts(fontPrint, fontFixed, fontFixedBold, fontArcane);
1751 final String name = args.get();
1752 final Image backgroundImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1753 final Font fontPrint = definedFonts.
lookup(args.get());
1754 final Font fontFixed = definedFonts.
lookup(args.get());
1755 final Font fontFixedBold = definedFonts.
lookup(args.get());
1756 final Font fontArcane = definedFonts.
lookup(args.get());
1758 final Fonts fonts =
new Fonts(fontPrint, fontFixed, fontFixedBold, fontArcane);
1770 final String name = args.get();
1773 final Object element = definedGUIElements.
lookup(name);
1775 throw new IOException(
"element '"+name+
"' is not of type 'log'");
1778 throw new IOException(
"invalid color index "+index);
1780 ((GUIMessageLog)element).setColor(index, color);
1790 final String name = args.get();
1791 final String type = args.get();
1803 throw new IOException(
"type '"+type+
"' is invalid");
1810 throw new IOException(ex);
1812 }
while (args.hasMore());
1816 final Object element = definedGUIElements.
lookup(name);
1818 throw new IOException(
"element '"+name+
"' is not of type 'log'");
1820 ((GUIMessageLog)element).setTypes(types);
1832 final String name = args.get();
1836 if (facesProvider == null) {
1837 throw new IOException(
"cannot create faces with size 4");
1839 final AbstractGUIElement element =
new GUIMiniMap(avoidCopyArea, tooltipManager, elementListener, name, mapUpdaterState, facesProvider, darknessColors, w, h);
1854 final String name = args.get();
1856 if (facesProvider == null) {
1857 throw new IOException(
"cannot create faces with size "+defaultTileSize);
1859 insertGuiElement(
new GUIMap(avoidCopyArea, tooltipManager, elementListener, name, mapUpdaterState, facesProvider, server, smoothFaces, darknessColors));
1872 final String name = args.get();
1875 final Image image = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
1876 final Font font = definedFonts.
lookup(args.get());
1880 final String format = args.get();
1881 final String tooltip = args.get();
1883 final AbstractGUIElement list =
new GUIMetaElementList(tooltipManager, elementListener, name, cellWidth, cellHeight, metaserverModel, image, font, format, tooltip, text, label, connectCommandList);
1896 final String name = args.get();
1897 final BufferedImage image = imageParser.
getImage(args.get());
1899 if (alpha < 0 || alpha > 1.0F) {
1900 throw new IOException(
"invalid alpha value: "+alpha);
1916 final String name = args.get();
1917 final Image activeImage = imageParser.
getImage(args.get());
1918 final Image inactiveImage = imageParser.
getImage(args.get());
1919 final Font font = definedFonts.
lookup(args.get());
1925 insertGuiElement(
new GUIQueryText(server, commandHistory, commandCallback, tooltipManager, elementListener, name, activeImage, inactiveImage, font, inactiveColor, activeColor, margin,
""));
1936 final Object forcedActive = definedGUIElements.
lookup(args.get());
1938 throw new IOException(
"argument to set_forced_active must be an activatable gui element");
1940 gui.setForcedActive((ActivatableGUIElement)forcedActive);
1954 gui.setAutoSize(
new Extent(x, y, w, h));
1964 definedGUIElements.
lookup(args.get()).setDefault(
true);
1974 definedGUIElements.
lookup(args.get()).setVisible(
false);
1988 throw new JXCSkinException(
"can't use hide_input on a non text field "+args.getPrev());
2010 final String name = args.get();
2012 final Object element = definedGUIElements.
lookup(args.get());
2016 throw new IOException(
"'"+element+
"' is not a scrollable element");
2018 insertGuiElement(
new GUIScrollBar(tooltipManager, elementListener, name, proportionalSlider, (GUIScrollable2)element, colorBackground, colorForeground));
2027 final String newSkinName = args.get();
2030 if (!newSkinName.matches(
"[-a-z_0-9]+")) {
2031 throw new IOException(
"invalid skin_name: "+newSkinName);
2033 if (minResolution.
getWidth() > maxResolution.getWidth() || minResolution.
getHeight() > maxResolution.getHeight()) {
2034 throw new IOException(
"minimum resolution ("+minResolution+
") must not exceed maximum resolution ("+maxResolution+
")");
2037 skin.
setSkinName(newSkinName, minResolution, maxResolution);
2050 final String name = args.get();
2051 final Image activeImage = imageParser.
getImage(args.get());
2052 final Image inactiveImage = imageParser.
getImage(args.get());
2053 final Font font = definedFonts.
lookup(args.get());
2060 insertGuiElement(
new GUITextField(commandCallback, commandHistory, tooltipManager, elementListener, name, activeImage, inactiveImage, font, inactiveColor, activeColor, margin,
"", commandList));
2073 if (textButtonFactory == null) {
2074 throw new IOException(
"missing 'def textbutton' command");
2077 final String name = args.get();
2081 assert textButtonFactory != null;
2095 if (dialogFactory == null) {
2096 throw new IOException(
"missing 'def dialog' command");
2099 final String name = args.get();
2100 final Image positiveImage = imageParser.
getImage(args.get());
2101 final Image negativeImage = args.get().equals(
"null") ? null : imageParser.
getImage(args.getPrev());
2102 final Image emptyImage = imageParser.
getImage(args.get());
2106 final Font font = definedFonts.
lookup(args.get());
2109 assert dialogFactory != null;
2111 final GUITextGauge element =
new GUITextGauge(tooltipManager, elementListener, name, positiveImage, negativeImage, emptyImage, orientation, tooltipPrefix.isEmpty() ? null : tooltipPrefix, color, font, alpha, commandList);
2125 final Font font = definedFonts.
lookup(args.get());
2126 final GUIHTMLLabel tooltipLabel =
new GUIHTMLLabel(tooltipManager, elementListener,
"tooltip", null, font, Color.BLACK, Color.WHITE,
"");
2141 private void parseVertical(@NotNull
final Args args, @NotNull
final Container gui, @NotNull
final LineNumberReader lnr,
final boolean isDialog)
throws IOException,
JXCSkinException {
2142 final GroupLayout layout = (GroupLayout)gui.getLayout();
2143 final String begin = args.get();
2144 if (!begin.equals(
"begin")) {
2145 throw new IOException(
"syntax error: expecting 'begin'");
2147 final Collection<GUIElement> unreferencedElements =
new TreeSet<>(
ELEMENT_COMPARATOR);
2148 for (
final GUIElement element : definedGUIElements) {
2149 unreferencedElements.add(element);
2152 final Group content =
parseBegin(args, layout, lnr, unreferencedElements);
2153 if (!unreferencedElements.isEmpty()) {
2154 throw new IOException(
"layout doesn't define elements "+unreferencedElements);
2156 layout.setVerticalGroup(content);
2160 if (background == null) {
2161 throw new AssertionError(
"element 'dialog_background' is missing");
2163 final Group content =
parseBegin(args, layout, lnr, unreferencedElements);
2166 final Group group2 = layout.createSequentialGroup();
2167 group2.addGap(DIALOG_BORDER_WIDTH);
2168 if (title == null) {
2169 if (close == null) {
2170 group2.addGroup(content);
2172 final Group group4 = layout.createParallelGroup();
2173 group4.addComponent(close);
2174 group4.addGap(0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
2175 final Group group3 = layout.createParallelGroup();
2176 group3.addGroup(content);
2177 group3.addGroup(group4);
2178 group2.addGroup(group3);
2181 if (close == null) {
2182 group2.addComponent(title);
2183 group2.addGroup(content);
2185 final Group group3 = layout.createParallelGroup();
2186 group3.addComponent(title);
2187 group3.addComponent(close);
2188 group2.addGroup(group3);
2189 group2.addGroup(content);
2192 group2.addGap(DIALOG_BORDER_WIDTH);
2193 if (!unreferencedElements.isEmpty()) {
2194 throw new IOException(
"layout doesn't define elements "+unreferencedElements);
2197 final Group group1 = layout.createParallelGroup();
2198 group1.addGroup(group2);
2199 group1.addComponent(background);
2201 layout.setVerticalGroup(group1);
2213 if (resolution == null) {
2214 throw new IOException(
"invalid resolution: "+resolution);
2229 final String name = args.get();
2232 final Font font = definedFonts.
lookup(args.get());
2243 definedGUIElements.
insert(guiElement.getName(), guiElement);
2263 private void addCommand(@NotNull
final String listName, @NotNull
final Args args, @Nullable
final AbstractGUIElement element, @NotNull
final String command, @NotNull
final GuiStateManager guiStateManager, @NotNull
final CommandExecutor commandExecutor, @NotNull
final LineNumberReader lnr, @NotNull
final CommandQueue commandQueue, @NotNull
final CrossfireServerConnection crossfireServerConnection, @NotNull
final CommandCallback commandCallback, @NotNull
final Macros macros)
throws IOException,
JXCSkinException {
2265 commandList.
add(commandParser.
parseCommandArgs(args, element, command, guiStateManager, commandExecutor, lnr, commandQueue, crossfireServerConnection, commandCallback, macros));
2292 private Group
parseBegin(@NotNull
final Args beginArgs, @NotNull
final GroupLayout layout, @NotNull
final LineNumberReader lnr, @NotNull
final Collection<GUIElement> unreferencedElements)
throws IOException,
JXCSkinException {
2293 final String type = beginArgs.get();
2297 group = layout.createSequentialGroup();
2301 group = layout.createParallelGroup();
2305 throw new IOException(
"undefined type '"+type+
"'");
2309 final String line = lnr.readLine();
2311 throw new IOException(
"unterminated 'begin' block");
2314 if (line.startsWith(
"#") || line.isEmpty()) {
2318 final String[] argsTmp;
2324 final Args args =
new Args(argsTmp);
2325 final String cmd = args.get();
2326 if (cmd.equals(
"end")) {
2331 group.addGroup(
parseBegin(args, layout, lnr, unreferencedElements));
2335 if (!(group instanceof SequentialGroup)) {
2336 throw new IOException(
"'border_gap' cannot be used outside 'seq' groups");
2338 ((SequentialGroup)group).addContainerGap();
2342 if (args.hasMore()) {
2344 if (args.hasMore()) {
2347 group.addGap(tmp, size, max);
2352 group.addGap(0, 1, Short.MAX_VALUE);
2358 if (!unreferencedElements.remove(element)) {
2359 throw new IOException(
"layout defines element '"+element+
"' more than once");
2361 if (args.hasMore()) {
2366 if (args.hasMore()) {
2375 group.addComponent(element, min, pref, max);
2377 group.addComponent(element);
2381 if (args.hasMore()) {
2382 throw new IOException(
"excess arguments");
FontParser fontParser
The FontParser for parsing font specifications.
Listener for GUIElement related events.
static Color parseColor(@NotNull final String name)
Parses a color name.
final KnowledgeView knowledgeView
A list to display spell skills.
void parseLabelFailure(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CrossfireServerConnection server)
Parses a "label_failure" command.
void parseText(@NotNull final Args args, @NotNull final CommandCallback commandCallback, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "text" command.
void parseIgnore(@NotNull final Args args)
Parses an "ignore" command.
final QuestsView questView
The QuestsView to use.
void parseLogLabel(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "log_label" command.
Abstract base class for all label classes.
A SkinEvent that executes a CommandList whenever a new skill has been gained.
A AbstractLabel that renders the text as a plain string.
static Orientation parseOrientation(@NotNull final String name)
Parses an orientation value.
void parseHorizontal(@NotNull final Args args, @NotNull final Container gui, @NotNull final LineNumberReader lnr, final boolean isDialog)
Parses a "horizontal" command.
void parseKey(@NotNull final Args args, @Nullable final Gui gui, @NotNull final String line)
Parses a "key" command.
void parseQueryText(@NotNull final Args args, @NotNull final CrossfireServerConnection server, @NotNull final CommandCallback commandCallback, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "query_text" command.
Provides a view of all quests a character is doing.
void parseMetaList(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final MetaserverModel metaserverModel)
Parses a "meta_list" command.
Maintains the current GuiState.
static final int NUM_COLORS
The number of supported colors.
void load(@NotNull final JXCSkinSource skinSource, @NotNull final String dialogName, @NotNull final String resourceName, @NotNull final InputStream inputStream, @NotNull final CrossfireServerConnection server, @NotNull final GuiStateManager guiStateManager, @NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final MetaserverModel metaserverModel, @NotNull final CharacterModel characterModel, @NotNull final CommandQueue commandQueue, @Nullable final Gui gui, @NotNull final Shortcuts shortcuts, @NotNull final CommandExecutor commandExecutor, @NotNull final CurrentSpellManager currentSpellManager, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros, @NotNull final Image nextGroupFace, @NotNull final Image prevGroupFace, @NotNull final SmoothFaces smoothFaces)
Loads a skin file and add the entries to a Gui instance.
A AbstractLabel that renders the text as a list of plain strings.
static FaceImages newFaceImages(@NotNull final ImageIcon originalImageIcon)
Creates a new FaceImages instance from an "original" face; the "scaled" and "magic map" sized images ...
final KeybindingsManager keybindingsManager
The KeybindingsManager containing key bindings.
Combines a list of GUIElements to for a gui.
Encapsulates the message type numbers for drawextinfo messages.
final GuiManager guiManager
The GuiManager to use.
JXCSkin load(@NotNull final JXCSkinSource skinSource, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final GuiStateManager guiStateManager, @NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final MetaserverModel metaserverModel, @NotNull final CharacterModel characterModel, @NotNull final CommandQueue commandQueue, @NotNull final Shortcuts shortcuts, @NotNull final CommandExecutor commandExecutor, @NotNull final CurrentSpellManager currentSpellManager, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros, @NotNull final GuiFactory guiFactory, @NotNull final SmoothFaces smoothFaces)
Loads the skin from its external representation.
final boolean avoidCopyArea
Whether map scrolling is done by copying pixel areas.
void parseKeyBinding(@NotNull final String line, final boolean isDefault)
Parses and add a key binding.
Encapsulates the extent of a GUI element.
A GUIItem for displaying inventory objects.
void parseSetInvisible(@NotNull final Args args)
Parses a "set_invisible" command.
void addDialog(@NotNull final String dialogName)
Defines a new dialog.
void parseCommandListAdd(@NotNull final Args args, @NotNull final GuiStateManager guiStateManager, @NotNull final LineNumberReader lnr, @NotNull final CommandExecutor commandExecutor, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection server, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros)
Parses a "commandlist_add" command.
A factory class to create "checkbox" instances.
Skill getNamedSkill(@NotNull final String skillName, final int face)
Returns the skill instance for a given skill name.
static final String PREV_GROUP_FACE
The resource for "Click here for previous group of items" buttons.
Utility class for creating FaceImages instances.
static final int DIALOG_BORDER_WIDTH
The border width of dialogs.
Utility class for string manipulation.
void parseTooltip(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "tooltip" command.
A GUIComboBox that shows available races for character creation.
TextButtonFactory textButtonFactory
The text button factory.
A GUIElement representing an in-game object in the ground view.
A factory class to create "textbutton" instances.
void parseHideInput(@NotNull final Args args)
Parses a "hide_input" command.
Iterable< AbstractGUIElement > newDialog(@NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final String title)
Creates a new dialog.
void insertGuiElement(@NotNull final GUIElement guiElement)
Adds a new GUIElement to this skin.
A GUIElement that fills an area with a given color.
void setAutoResize(final boolean autoResize)
Enable or disable auto-resizing.
static void parseSetModal(@NotNull final Gui gui)
Parses a "set_modal" command.
final KnowledgeTypeView knowledgeTypeView
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.
void parseCheckbox(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "checkbox" command.
static< T extends Enum< T > T parseEnum(@NotNull final Class< T > class_, @NotNull final String name, @NotNull final String ident)
Parses an enum constant.
Group parseBegin(@NotNull final Args beginArgs, @NotNull final GroupLayout layout, @NotNull final LineNumberReader lnr, @NotNull final Collection< GUIElement > unreferencedElements)
Parses a "begin..end" block.
ItemPainter newItemPainter()
Creates a new instance having the same parameters as this instance except for the item's size...
float getFrameAlpha()
Returns the alpha value for the frame background.
A SkinEvent that executes a CommandList at connection setup.
A GUIHTMLLabel that displays the last received "query" command.
Parser for integer expressions.
A CheckBoxOption that executes CommandLists when checked/unchecked.
void parseLabelMessage(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CrossfireServerConnection server, @NotNull final JXCWindowRenderer windowRenderer)
Parses a "label_message" command.
Interface for orientation images.
void parseMap(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CrossfireServerConnection server, @NotNull final SmoothFaces smoothFaces)
Parses a "map" command.
static Expression parseExpression(@NotNull final String str)
Parses an integer constant.
static int parseInt(@NotNull final String str)
Parses an integer constant.
A GUIItemList for inventory views.
void parseLabelText(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "label_text" command.
final KeyBindings defaultKeyBindings
The default key bindings.
final FacesProviderFactory facesProviderFactory
The FacesProviderFactory instance for creating faces provider instances.
Parser for loading JXCSkin instances from JXCSkinSources.
void setTooltipLabel(@Nullable final AbstractLabel tooltipLabel)
Sets the AbstractLabel that is used to display tooltips.
KNOWLEDGE_LIST
Create a GUIKnowledgeList instance.
GROUND
Create a GUIFloorList instance.
CommandParser commandParser
The CommandParser for parsing commands.
Implements the map model which is shown in the map and magic map views.
void addCommandList(@NotNull final String commandListName, @NotNull final CommandListType commandListType)
Defines a new command list.
Maintains a set of named options.
A gui element implementing the message window.
void parseLogFilter(@NotNull final Args args)
Parses a "log_filter" command.
KnowledgeManager getKnowledgeManager()
final FacesManager facesManager
The FacesManager instance to use.
static final String ALL_SPELL_SKILLS_ICON
The resource name for the default skill face.
static Resolution parseResolution(@NotNull final String text)
Parses a resolution specification.
Component getUnreferencedElement(@NotNull final String name, @NotNull final Collection< GUIElement > unreferencedElements)
Returns an unreferenced GUI element by name.
GUIText lookupTextElement(@NotNull final String name)
Returns a GUIText by element name.
Manages image information ("faces") needed to display the map view, items, and spell icons...
An exception that is thrown if an undefined message type occurs.
static Resolution parse(@NotNull final String str)
Creates a new instance from string representation.
Consists of three ImageIcons representing a Face.
A SkinEvent that executes a CommandList whenever a magicmap protocol command is received.
Creates GaugeUpdater instances from string representations.
A GUIItemList for floor views.
int getWidth()
Returns the width in pixels.
Utility class for parsing string parameters into values.
final JXCSkinCache< Font > definedFonts
All defined fonts.
final CommandHistoryFactory commandHistoryFactory
The CommandHistoryFactory to use.
static float parseFloat(@NotNull final String str)
Parses a float constant.
Displays knowledge items the player knows.
ItemPainter defaultItemPainter
The ItemPainter for default item parameters.
static ImageIcon loadImage(@NotNull final String name)
Loads an image file.
A gui element implementing a static text field which may contain media tags.
void add(@NotNull final GUICommand guiCommand)
Adds a command to the end of this command list.
A GUIItemItem that represents an entry in a GUISpellList.
Defines a JXClient skin consisting of a main Gui and zero or more dialog Guis.
void parseScrollbar(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "scrollbar" command.
int getHeight()
Returns the height in pixels.
Iterator< T > iterator()
Returns all stored values.
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...
An expression yielding an integer value derived from a screen resolution.
void parseSetDefault(@NotNull final Args args)
Parses a "set_default" command.
Interface defining an abstract GUI element.
One skill of the character.
A factory for creating FacesProvider instances.
Manages macro expansion in command strings.
Combines all model classes that are updated.
A GUIElement that can be set to active or inactive.
Creates Font instances from string representations.
Renders a Gui instance into a Frame.
Exception thrown for unterminated quoted tokens.
void parseLabelQuery(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CrossfireServerConnection server)
Parses a "label_query" command.
static int parseStat(@NotNull final String name)
Parses a stat value.
Provides a view of all spells a character knows.
final MapUpdaterState mapUpdaterState
The MapUpdaterState instance to use.
ImageParser imageParser
The ImageParser for parsing image specifications.
void parseEvent(@NotNull final Args args, @NotNull final GuiStateManager guiStateManager, @NotNull final CrossfireServerConnection server)
Parses an "event" command.
Interface for face providers.
Font getFont(@NotNull final String name)
Returns a font by font file base name.
void parseDef(@NotNull final Args args, @NotNull final LineNumberReader lnr)
Parses a "def" command.
Image getImage(@Nullable final Color color, @NotNull final String name)
Optionally loads an image by base file name.
void parseTextButton(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "textbutton" command.
final SpellSkillView spellSkillsView
The SpellSkillView to use.
void parsePicture(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "picture" command.
Manages the currently selected spell.
The kind of list to create in ListType, TooltipManager, GUIElementListener, CommandQueue, CrossfireServerConnection, CurrentSpellManager, Image, Image).
Factory for creating Gui instances.
GuiElementParser guiElementParser
The GuiElementParser for parsing gui element specifications.
Utility class for loading information from resources.
A GUIHTMLLabel that displays the last received "failure" message.
Indicates that a key binding is invalid.
SPELL
Create a GUISpellList instance.
void parseLabelHtml(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "label_html" command.
void parseCommandList(@NotNull final Args args, @NotNull final GuiStateManager guiStateManager, @NotNull final LineNumberReader lnr, @NotNull final CommandExecutor commandExecutor, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection server, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros)
Parses a "commandlist" command.
void parseLogColor(@NotNull final Args args)
Parses a "log_color" command.
void insert(@NotNull final String name, @NotNull final T t)
Adds a new element to the cache.
QUEST
Create a GUIQuestList instance.
final SpellsView spellView
The SpellsView to use.
A GUILabel that displays a value of the last received "stats" command.
A GUIList instance that displays GUIItemItem instances.
AbstractGUIElement newCheckBox(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final CheckBoxOption option, @NotNull final String text)
Creates a new checkbox.
Displays a shortcut command.
A GUIText element that executes the entered text as a command.
static boolean parseBoolean(@NotNull final String str)
Parses a boolean constant.
Interface for providers of JXCSkin sources.
static final String NEXT_GROUP_FACE
The resource for "Click here for next group of items" buttons.
static final Comparator< GUIElement > ELEMENT_COMPARATOR
A Comparator that compares GUIElement instances by element name.
SPELL_SKILLS
Create a GUISpellSkillList instance.
A SkinEvent that executes a CommandList at connection setup.
Maintains the application's main GUI state.
void parseTextGauge(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "textgauge" command.
A GUIComboBox that shows available classes for character creation.
void parseComboBox(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "combobox" command.
void addCommand(@NotNull final String listName, @NotNull final Args args, @Nullable final AbstractGUIElement element, @NotNull final String command, @NotNull final GuiStateManager guiStateManager, @NotNull final CommandExecutor commandExecutor, @NotNull final LineNumberReader lnr, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros)
Parses and builds command arguments.
final JXCSkinCache< AbstractGUIElement > definedGUIElements
The defined GUIElements.
Interface that defines callback functions needed by commands.
A GUIList display characters of an account.
Update a CfMap model from protocol commands.
void clear()
Forgets all cached elements.
final FloorView floorView
The FloorView to use.
A GUIHTMLLabel that displays the last received "drawinfo" message.
void parseItem(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection server, @NotNull final Shortcuts shortcuts, @NotNull final CurrentSpellManager currentSpellManager, @NotNull final Image nextGroupFace, @NotNull final Image prevGroupFace)
Parses an "item" command.
AbstractLabel lookupLabelElement(@NotNull final String name)
Returns a AbstractLabel by element name.
static String [] splitFields(@NotNull final String line)
Splits a line into tokens.
All gui states of JXCWindowRenderer.
GaugeUpdater parseGaugeUpdater(@NotNull final String name, @NotNull final ExperienceTable experienceTable)
Parses a gauge updater value.
A GUILabel that displays a value of the last received "stats" command.
final int defaultTileSize
The default tile size for the map view.
A GUIHTMLLabel that displays the currently selected spell.
GaugeUpdater newGaugeUpdater(@NotNull final String name)
Creates a new GaugeUpdater instance from a string representation.
void parseCommandText(@NotNull final Args args, @NotNull final CommandCallback commandCallback, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CommandExecutor commandExecutor)
Parses a "command_text" command.
T lookupOptional(@NotNull final String name)
Looks up an element by name.
void addInitEvent(@NotNull final CommandList commandList)
Adds a command list to be executed on "init" events.
GaugeUpdaterParser gaugeUpdaterParser
The GaugeUpdaterParser for parsing gauge specifications.
INVENTORY
Create a GUIItemList instance.
final DarknessColors darknessColors
The DarknessColors instance for converting darkness values into colors.
final ItemView inventoryView
The inventory ItemView to use.
void parseList(@NotNull final Args args, final ListType type, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection server, @NotNull final CurrentSpellManager currentSpellManager, @NotNull final Image nextGroupFace, @NotNull final Image prevGroupFace)
Parses an "inventory_list", "floor_list", "spells_list" or "quests_list" command. ...
Updates the displayed values in a GUIGauge.
KeyBindings getDefaultKeyBindings()
Returns the default key bindings for this skin.the default key bindings
void parseButton(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "button" command.
static Color parseColorNull(@NotNull final String name)
Parses a color name, optionally followed by "/<alpha>".
ExperienceTable getExperienceTable()
static void parseSetAutoSize(@NotNull final Gui gui, @NotNull final Args args)
Parses a "set_auto_size" command.
Default JXCSkin implementation.
Maintains the character list for an account.
void parseFont(@NotNull final Args args)
Parses a "font" command.
String getDialogToLoad()
Returns one dialog pending loading.
void parseLinkSize(@NotNull final Args args, @NotNull final Container gui)
Parses a "link_size" command.
JXCSkinLoader(@NotNull final Model model, @NotNull final ItemView inventoryView, @NotNull final FloorView floorView, @NotNull final SpellsView spellView, @NotNull final SpellSkillView spellSkillsView, @NotNull final FacesManager facesManager, @NotNull final MapUpdaterState mapUpdaterState, @NotNull final KeyBindings defaultKeyBindings, @NotNull final OptionManager optionManager, final int defaultTileSize, @NotNull final KeybindingsManager keybindingsManager, @NotNull final QuestsView questView, @NotNull final CommandHistoryFactory commandHistoryFactory, @NotNull final KnowledgeView knowledgeView, @NotNull final KnowledgeTypeView knowledgeTypeView, final boolean avoidCopyArea, @NotNull final GuiManager guiManager)
Creates a new instance.
final Model model
The Model instance to use.
Implements a cache for elements identified by name.
void setGauge(@NotNull final GUIGaugeListener gauge)
Sets the gauge to update.
A SkinEvent that executes a CommandList whenever a new skill has been lost.
Displays a small map view.
Utility class for parsing strings into numbers.
Exception thrown if a skin related problem occurs.
void insertGuiElement(@NotNull final AbstractGUIElement guiElement)
Adds a new GUIElement to this skin.
Displays a value as a graphical gauge that's filling state depends on the value.
A GUIList to display quests.
DefaultJXCSkin skin
The JXCSkin being loaded.
A GUIItemList displaying spell skills.
A text input field which executes a CommandList when ENTER is pressed.
void parseFill(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "fill" command.
final OptionManager optionManager
The OptionManager instance to use.
void parseLogMessage(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CrossfireServerConnection server)
Parses a "log_message" command.
Implements an AbstractLabel that displays HTML contents.
Utility class for converting darkness values into colors.
void parseDupGauge(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "dupgauge" command.
void parseVertical(@NotNull final Args args, @NotNull final Container gui, @NotNull final LineNumberReader lnr, final boolean isDialog)
Parses a "vertical" command.
Abstract base class for GUI elements to be shown in Guis.
Manages a list of previously entered commands.
Factory for creating CommandHistory instances by name.
void clear()
Forgets all defined images.
void addSkinEvent(@NotNull final SkinEvent skinEvent)
Records a SkinEvent attached to this instance.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
Displays a value as a graphical gauge that's filling state depends on the value.
Maintains the pending (ncom) commands sent to the server.
KNOWLEDGE_TYPES
Create a GUIKnowledgeTypeList instance.
void parseLabelMulti(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "label_multi" command.
static CheckBoxOption parseCheckBoxOption(@NotNull final String name, @NotNull final OptionManager optionManager)
Parses a check box option name.
void load(@NotNull final JXCSkinSource skinSource, @NotNull final String dialogName, @NotNull final CrossfireServerConnection server, @NotNull final GuiStateManager guiStateManager, @NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final MetaserverModel metaserverModel, @NotNull final CharacterModel characterModel, @NotNull final CommandQueue commandQueue, @Nullable final Gui gui, @NotNull final Shortcuts shortcuts, @NotNull final CommandExecutor commandExecutor, @NotNull final CurrentSpellManager currentSpellManager, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros, @NotNull final Image nextGroupFace, @NotNull final Image prevGroupFace, @NotNull final SmoothFaces smoothFaces)
Loads a skin file and add the entries to a Gui instance.
Information about JXClient's screen/window resolution.
Creates gui element instances from string representations.
A list of GUICommand instances.
SpellsManager getSpellsManager()
The base class for all check box options.
static void parseDialogHide(@NotNull final Args args, @NotNull final Gui gui)
Parses a "dialog_hide" command.
A GUIDupGauge which displays the current value as a text string on top of the gauge.
void parseSetForcedActive(@NotNull final Args args, @NotNull final Gui gui)
Parses a "set_forced_active" command.
void parseDupTextGauge(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "duptextgauge" command.
A GUIList to display spells.
void parseCharacterList(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CharacterModel characterModel)
Parses a "character_list" command.
DialogFactory dialogFactory
The dialog factory.
CommandHistory getCommandHistory(@NotNull final String ident)
Returns a CommandHistory instance by name.
GUILabelLog lookupLabelLogElement(@NotNull final String name)
Returns a AbstractLabel by element name.
Adds drawinfo, drawextinfo, and query messages to a Buffer instance.
Parser for creating GUICommand instances from string representations.
static String parseText(@NotNull final Args args, @NotNull final LineNumberReader lnr)
Concatenates trailing arguments into a string.
Manages a list of Shortcuts.
Paints Crossfire item images.
Manages a set of key bindings.
A factory class to create "textbutton" instances.
GUICommand parseCommandArgs(@NotNull final Args args, @Nullable final AbstractGUIElement element, @NotNull final String command, @NotNull final GuiStateManager guiStateManager, @NotNull final CommandExecutor commandExecutor, @NotNull final LineNumberReader lnr, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros)
Parses and builds command arguments.
AbstractGUIElement newTextButton(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final String text, final boolean autoRepeat, @NotNull final CommandList commandList)
Creates a new text button.
QuestsManager getQuestsManager()
Maintains a set of Gui instances representing dialog windows.
void parseGauge(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr)
Parses a "gauge" command.
void parseLabelSpell(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CurrentSpellManager currentSpellManager)
Parses a "label_spell" command.
void parseSkinName(@NotNull final Args args)
Parses a "skin_name" command.
T lookup(@NotNull final String name)
Looks up an element by name.
CheckBoxFactory checkBoxFactory
The checkbox factory.
void parseLabelStat2(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "label_stat2" command.
Creates BufferedImage instances from string representations.
FacesProvider getFacesProvider(final int size)
Returns the FacesProvider for a given face size.
static int parseMessageType(@NotNull final String str)
Parses a string into a message type.
A GUIGauge which displays the current value as a text string on top of the gauge. ...
void parseLabelStat(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "label_stat" command.
A AbstractGUIElement that displays a picture.
Maintains smoothing information received from the Crossfire server.
void parseMinimap(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener)
Parses a "minimap" command.
Abstract base class for text input fields.
Input field for "query" dialogs.
Gui getDialog(@NotNull final String name)
Returns a dialog by name.the dialog's name the dialog if the dialog does not exist ...
Provides a view to all items comprising the current floor view.
void setHideInput(final boolean hideInput)
Enables or disables hidden text.
void parseDialog(@NotNull final Args args, @NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final LineNumberReader lnr, @NotNull final Gui gui, @NotNull final String dialogName)
Parses a "dialog" command.
Maintains a mapping of face numbers to face data.