 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.label;
30 import java.util.EnumMap;
31 import java.util.Iterator;
32 import java.util.List;
34 import java.util.Objects;
35 import java.util.TreeMap;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
49 private static final String
UNKNOWN =
"unknown";
154 private final Map<Integer, String>
errorTexts =
new TreeMap<>();
166 public void classListChanged() {
172 public void classInfoChanged(@NotNull
final String className) {
177 public void raceListChanged() {
183 public void raceInfoChanged(@NotNull
final String raceName) {
188 public void startingMapListChanged() {
194 public void startingMapInfoChanged(@NotNull
final String startingMapName) {
245 final String newRace;
246 if (list.contains(
race)) {
248 }
else if (!list.isEmpty()) {
249 newRace = list.get(0);
253 if (this.race.equals(newRace)) {
277 final String newClass;
278 if (list.contains(
class_)) {
280 }
else if (!list.isEmpty()) {
281 newClass = list.get(0);
285 if (this.class_.equals(newClass)) {
289 this.class_ = newClass;
309 final String newStartingMap;
312 }
else if (!list.isEmpty()) {
313 newStartingMap = list.get(0);
317 if (this.startingMap.equals(newStartingMap)) {
321 this.startingMap = newStartingMap;
341 final Integer prevValue =
values.put(stat, value);
343 if (prevValue ==
null || !prevValue.equals(value)) {
354 final Integer tmp =
values.get(stat);
355 return tmp ==
null ? 0 : tmp;
383 public void setErrorText(
final int priority, @Nullable
final String text) {
384 final String prevText =
errorTexts.get(priority);
386 if (!Objects.equals(text, prevText)) {
397 final Iterator<String> it =
errorTexts.values().iterator();
398 return it.hasNext() ? it.next() :
"";
406 final Iterator<Integer> it =
errorTexts.keySet().iterator();
427 for (
int value :
values.values()) {
456 if (this.optionIndex == newOptionIndex) {
459 this.optionIndex = newOptionIndex;
467 @Nullable
final Choice newOption;
469 if (raceInfo !=
null && !raceInfo.
getChoices().isEmpty()) {
473 if (classInfo !=
null && !classInfo.
getChoices().isEmpty()) {
479 if (!Objects.equals(
option, newOption)) {
One possible class or race for character creation.
int getPoints()
Returns the number of points the character has to spend.
int getTotal(@NotNull final NewcharStat stat)
Returns the total points (sum of base, race, and class) for a stat.
final EventListenerList2< NewCharModelListener > listeners
The listeners to notify about changes.
String race
The selected race.
static final int PRIORITY_INVALID_STAT_DEX
A priority value for setErrorText(int, String).
int getValue(@NotNull final NewcharStat stat)
Returns the base points for a stat.
void addListener(@NotNull final NewCharModelListener listener)
Adds a listener to notify of changes.
NewCharacterInformation getNewCharacterInformation()
Returns the NewCharacterInformation instance received from the server.
final NewCharacterInformation newCharacterInformation
The options received from the server.
int getOptionIndex()
Return the selected character option.
static final int PRIORITY_INVALID_STAT_CHA
A priority value for setErrorText(int, String).
long getStatAdjustment(final int statNo)
Returns a stat adjustment.
String getErrorText()
Returns the error text to show.
static final String UNKNOWN
The class or race name to use if no (or no valid) class or race exists.
Interface for listeners interested in NewCharModel related changes.
A list of event listeners.
void setClass(@NotNull final String class_)
Sets the selected class.
String getClass_()
Returns the selected class.
int getUnusedPoints()
Returns the number of unused attribute points.
A choice for character creation.
int optionIndex
The selected index in option.
void setRace(@NotNull final String race)
Sets the selected race.
static final int PRIORITY_CHARACTER_NAME
A priority value for setErrorText(int, String).
String startingMap
The selected starting map.
int getClassStatAdjustment(@NotNull final NewcharStat stat)
Returns the class points for a stat.
void setErrorText(final int priority, @Nullable final String text)
Sets an error text.
Choice option
The shown choice.
static final int PRIORITY_INVALID_STAT_STR
A priority value for setErrorText(int, String).
final Map< Integer, String > errorTexts
The error text(s) to show.
void notifyListeners()
Notifies all listeners about a change.
static final int PRIORITY_INVALID_STAT_WIS
A priority value for setErrorText(int, String).
General information for creating new characters.
int getRaceStatAdjustment(@NotNull final NewcharStat stat)
Returns the race points for a stat.
static final int PRIORITY_INVALID_STAT_CON
A priority value for setErrorText(int, String).
void removeListener(@NotNull final NewCharModelListener listener)
Removes a listener to be notified of changes.
static final int PRIORITY_SERVER_FAILURE
A priority value for setErrorText(int, String).
String class_
The selected class.
List< Choice > getChoices()
Returns the available choices.
NewCharModel(@NotNull final NewCharacterInformation newCharacterInformation)
Creates a new instance.
String getRace()
Returns the selected race.
Choice getOption()
Returns the character options.
void updateOption()
Updates option if necessary.
void setValue(@NotNull final NewcharStat stat, final int value)
Sets the base points for a stat.
void setStartingMap(@NotNull final String startingMap)
Sets the selected starting map.
void setOptionIndex(final int optionIndex)
Sets the selected character option.
String getStartingMap()
Returns the selected starting map.
static final int PRIORITY_UNUSED_POINTS
A priority value for setErrorText(int, String).
final Map< NewcharStat, Integer > values
The base attribute values.
Map< String, String > getChoices()
Returns the choices.
boolean hasNonServerFailureErrorText()
Returns the error text to show.
static final int PRIORITY_INVALID_STAT_INT
A priority value for setErrorText(int, String).
static final int PRIORITY_INVALID_STAT_POW
A priority value for setErrorText(int, String).