Crossfire JXClient, Trunk  R20561
GUISpellSkillList.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.gui.list;
23 
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
36 
41 public class GUISpellSkillList extends GUIItemList<GUIItemSpellSkill> {
42 
46  private static final long serialVersionUID = 1L;
47 
51  @NotNull
53 
57  @NotNull
59 
63  @NotNull
64  private final String name;
65 
69  @NotNull
70  private final ItemView itemView;
71 
75  @NotNull
77 
81  @NotNull
82  private final ItemPainter itemPainter;
83 
87  @NotNull
88  private final FacesManager facesManager;
89 
93  @NotNull
95 
112  public GUISpellSkillList(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final int cellWidth, final int cellHeight, @NotNull final ItemView itemView, @Nullable final AbstractLabel currentItem, @NotNull final SpellsManager spellsManager, @NotNull final ItemPainter itemPainter, @NotNull final FacesManager facesManager, @NotNull final FaceImages defaultSkillIcon) {
113  super(tooltipManager, elementListener, name, cellWidth, cellHeight, itemView, currentItem, new GUIItemSpellSkill(tooltipManager, elementListener, name+"_template", itemPainter, -1, facesManager, spellsManager, itemView, defaultSkillIcon, cellHeight));
114  this.tooltipManager = tooltipManager;
115  this.elementListener = elementListener;
116  this.name = name;
117  this.itemView = itemView;
118  this.spellsManager = spellsManager;
119  this.itemPainter = itemPainter;
120  this.facesManager = facesManager;
121  this.defaultSkillIcon = defaultSkillIcon;
122  }
123 
127  @Override
128  @SuppressWarnings("IfMayBeConditional")
129  protected void updateTooltip(final int index, final int x, final int y, final int w, final int h) {
130  final Skill skill = spellsManager.getSpellSkill(index);
131  final String text;
132  if (skill == null) {
133  text = "";
134  } else if (skill.getLevel() > 0) {
135  text = skill+" (level "+skill.getLevel()+")";
136  } else {
137  text = skill.toString();
138  }
139  setTooltipText(text, x, y, w, h);
140  }
141 
145  @NotNull
146  @Override
147  protected GUIItemSpellSkill newItem(final int index) {
149  }
150 
154  @Override
155  protected void selectionChanged(final int selectedIndex) {
156  if (spellsManager == null) {
157  return;
158  }
159  spellsManager.filterSkill(selectedIndex);
160  super.selectionChanged(selectedIndex);
161  }
162 
163 }
Abstract base class for all label classes.
final GUIElementListener elementListener
The GUIElementListener to notify.
final FacesManager facesManager
The FacesManager to use.
final SpellsManager spellsManager
The spells to display.
int getLevel()
Returns the skill level.
Definition: Skill.java:97
Manages image information ("faces") needed to display the map view, items, and spell icons...
Consists of three ImageIcons representing a Face.
Definition: FaceImages.java:31
One skill of the character.
Definition: Skill.java:32
void updateTooltip(final int index, final int x, final int y, final int w, final int h)
GUISpellSkillList(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final int cellWidth, final int cellHeight, @NotNull final ItemView itemView, @Nullable final AbstractLabel currentItem, @NotNull final SpellsManager spellsManager, @NotNull final ItemPainter itemPainter, @NotNull final FacesManager facesManager, @NotNull final FaceImages defaultSkillIcon)
Creates a new instance.
final String name
The base name for created elements.
final TooltipManager tooltipManager
The TooltipManager to update.
A GUIList instance that displays GUIItemItem instances.
final ItemPainter itemPainter
The ItemPainter for painting the icon.
void filterSkill(final int index)
Filters spells to display by the specified skill index.
final FaceImages defaultSkillIcon
The default FaceImages to use for the skills if not defined.
Skill getSpellSkill(final int index)
Returns the specified spell skill.
static final long serialVersionUID
The serial version UID.
final AbstractLabel currentItem
The label to update with information about the selected item.
Maintains a mapping of face numbers to face data.