Crossfire JXClient, Trunk
GaugeUpdaterParser.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-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.skin.io;
24 
35 import java.io.IOException;
36 import org.jetbrains.annotations.NotNull;
37 
42 public class GaugeUpdaterParser {
43 
47  @NotNull
48  private final Stats stats;
49 
53  @NotNull
54  private final ItemSet itemSet;
55 
59  @NotNull
60  private final SkillSet skillSet;
61 
68  public GaugeUpdaterParser(@NotNull final Stats stats, @NotNull final ItemSet itemSet, @NotNull final SkillSet skillSet) {
69  this.stats = stats;
70  this.itemSet = itemSet;
71  this.skillSet = skillSet;
72  }
73 
81  @NotNull
82  public GaugeUpdater parseGaugeUpdater(@NotNull final String name, @NotNull final ExperienceTable experienceTable) throws IOException {
83  try {
84  return new StatGaugeUpdater(experienceTable, StatsParser.parseStat(name), stats, itemSet);
85  } catch (final IllegalArgumentException ignored) {
86  // ignore
87  }
88 
89  if (name.startsWith("SKILL_")) {
90  return new SkillGaugeUpdater(experienceTable, skillSet.getNamedSkill(name.substring(6).replaceAll("_", " "), -1));
91  }
92 
93  if (name.startsWith("ACTIVE_SKILL_")) {
94  return new ActiveSkillGaugeUpdater(experienceTable, name.substring(13).replaceAll("_", " "), stats);
95  }
96 
97  if (name.equals("ACTIVE_SKILL")) {
98  return new ActiveSkillGaugeUpdater2(experienceTable, stats, skillSet);
99  }
100 
101  throw new IOException("invalid stat name: "+name);
102  }
103 
104 }
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.skills.SkillSet.getNamedSkill
Skill getNamedSkill(@NotNull final String skillName, final int face)
Definition: SkillSet.java:161
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser.GaugeUpdaterParser
GaugeUpdaterParser(@NotNull final Stats stats, @NotNull final ItemSet itemSet, @NotNull final SkillSet skillSet)
Definition: GaugeUpdaterParser.java:68
com.realtime.crossfire.jxclient.stats.StatsParser.parseStat
static int parseStat(@NotNull final String name)
Definition: StatsParser.java:140
com.realtime.crossfire.jxclient.gui.gauge.ActiveSkillGaugeUpdater2
Definition: ActiveSkillGaugeUpdater2.java:37
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser.stats
final Stats stats
Definition: GaugeUpdaterParser.java:48
com.realtime.crossfire.jxclient.gui.gauge.GaugeUpdater
Definition: GaugeUpdater.java:33
com.realtime.crossfire.jxclient.items.ItemSet
Definition: ItemSet.java:44
com.realtime.crossfire.jxclient.stats.Stats
Definition: Stats.java:44
com.realtime.crossfire.jxclient.gui.gauge
Definition: AbstractOrientation.java:23
com.realtime.crossfire.jxclient.gui.gauge.StatGaugeUpdater
Definition: StatGaugeUpdater.java:39
com.realtime.crossfire.jxclient.skills
Definition: Skill.java:23
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.stats.ExperienceTable
Definition: ExperienceTable.java:33
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser.itemSet
final ItemSet itemSet
Definition: GaugeUpdaterParser.java:54
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser.parseGaugeUpdater
GaugeUpdater parseGaugeUpdater(@NotNull final String name, @NotNull final ExperienceTable experienceTable)
Definition: GaugeUpdaterParser.java:82
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser.skillSet
final SkillSet skillSet
Definition: GaugeUpdaterParser.java:60
com.realtime.crossfire.jxclient.skin.io.GaugeUpdaterParser
Definition: GaugeUpdaterParser.java:42
com.realtime.crossfire
com.realtime
com
com.realtime.crossfire.jxclient.items
Definition: AbstractItemView.java:23
com.realtime.crossfire.jxclient.stats.StatsParser
Definition: StatsParser.java:33
com.realtime.crossfire.jxclient.gui.gauge.SkillGaugeUpdater
Definition: SkillGaugeUpdater.java:34
com.realtime.crossfire.jxclient.gui.gauge.ActiveSkillGaugeUpdater
Definition: ActiveSkillGaugeUpdater.java:34
com.realtime.crossfire.jxclient.skills.SkillSet
Definition: SkillSet.java:39
com.realtime.crossfire.jxclient.stats
Definition: ActiveSkillWatcher.java:23