22 package com.realtime.crossfire.jxclient.gui.label;
28 import java.awt.Color;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
109 public void reset() {
114 public void statChanged(
final int statNo,
final int value) {
115 if (statNo == statCurrent || statNo == statBase || statNo == statRace || statNo == statApplied) {
121 public void simpleWeaponSpeedChanged(
final boolean simpleWeaponSpeed) {
126 public void titleChanged(@NotNull
final String title) {
131 public void rangeChanged(@NotNull
final String range) {
136 public void activeSkillChanged(@NotNull
final String activeSkill) {
141 public void experienceChanged(
final long exp) {
146 public void experienceNextLevelChanged(
final long expNextLevel) {
171 public GUILabelStats2(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @NotNull
final Font font, @NotNull
final Color colorNormal, @NotNull
final Color colorUpgradable, @NotNull
final Color colorDepleted, @NotNull
final Color colorBoosted, @NotNull
final Color colorBoostedUpgradable, @Nullable
final Color
backgroundColor,
final int statCurrent,
final int statBase,
final int statRace,
final int statApplied, @NotNull
final Alignment alignment, @NotNull
final Stats stats) {
172 super(tooltipManager, elementListener, name, null, font, colorNormal, backgroundColor, alignment,
"");
191 final int baseValue = stats.
getStat(statBase);
192 final int raceValue = stats.
getStat(statRace);
193 final int appliedValue = stats.
getStat(statApplied);
194 final int currValue = stats.
getStat(statCurrent);
195 final int currValueWithoutGear = currValue-appliedValue;
196 if (baseValue == 0 && raceValue == 0) {
199 setText(String.valueOf(currValue));
204 final Color newColor;
205 if (currValueWithoutGear < baseValue) {
207 }
else if (currValueWithoutGear == baseValue) {
212 if (color != newColor) {
216 setText(String.valueOf(currValue));
218 final StringBuilder sb =
new StringBuilder();
219 sb.append(
"<html>Current: ").append(currValue);
220 if (currValueWithoutGear < baseValue) {
221 sb.append(
"<br>Depleted by ").append(baseValue-currValueWithoutGear).append(
" from ").append(baseValue).append(
".");
222 }
else if (currValueWithoutGear > baseValue) {
223 sb.append(
"<br>Increased by ").append(currValueWithoutGear-baseValue).append(
" from ").append(baseValue).append(
".");
225 if (appliedValue > 0) {
226 sb.append(
"<br>Boosted by ").append(appliedValue).append(
" by gear or skills.");
227 }
else if (appliedValue < 0) {
228 sb.append(
"<br>Reduced by ").append(-appliedValue).append(
" by gear or skills.");
230 if (baseValue < raceValue) {
231 sb.append(
"<br>Upgradable to ").append(raceValue).append(
" by drinking stat potions.");
Listener for GUIElement related events.
final int statBase
The base stat without applied boosts or depletions.
A AbstractLabel that renders the text as a plain string.
final Color colorDepleted
The color for depleted stats.
void setText(@NotNull final String text)
The label text.
final StatsListener statsListener
The StatsListener registered to be notified about stat changes.
final int statApplied
The stat change due to gear or skills.
final TooltipManager tooltipManager
The TooltipManager to update.
final Color colorBoosted
The color for boosted stats.
void setChanged()
Records that the contents have changed and must be repainted.
void removeCrossfireStatsListener(@NotNull final StatsListener statsListener)
Removes a StatsListener to be notified about stat changes.
Color color
The current color.
final GUIElementListener elementListener
The GUIElementListener to notify.
GUILabelStats2(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final Font font, @NotNull final Color colorNormal, @NotNull final Color colorUpgradable, @NotNull final Color colorDepleted, @NotNull final Color colorBoosted, @NotNull final Color colorBoostedUpgradable, @Nullable final Color backgroundColor, final int statCurrent, final int statBase, final int statRace, final int statApplied, @NotNull final Alignment alignment, @NotNull final Stats stats)
Creates a new instance.
final int statCurrent
The current stat.
void updateStat()
Updates the values to reflect the current stat value.
final Color backgroundColor
If set, the opaque background color.
final String name
The name of this element.
void addCrossfireStatsListener(@NotNull final StatsListener statsListener)
Adds a StatsListener to be notified about stat changes.
static final long serialVersionUID
The serial version UID.
A GUILabel that displays a value of the last received "stats" command.
final Color colorUpgradable
The color for upgradable stats.
void setTooltipText(@Nullable final String tooltipText)
Sets the tooltip text to show when the mouse is inside this element.the text to show ornull to disab...
Interface for listeners interested in changes of Stats instances.
void dispose()
Releases all allocated resources.
final int statRace
The race's maximum stat.
final Stats stats
The Stats instance to use.
This is the representation of all the statistics of a player, like its speed or its experience...
final Color colorBoostedUpgradable
The color for boosted and upgradable stats.
int getStat(final int statNo)
Returns the numerical value of the given statistic.