mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-22 12:38:12 +07:00
Improved charged skill icons
This commit is contained in:
parent
961acb0df1
commit
b8449d6f42
@ -36,6 +36,7 @@ public class CharData {
|
||||
private final IntIntMap equippedSets = new IntIntMap(); // Indexed using set id
|
||||
private final IntIntMap setItemsOwned = new IntIntMap(); // Indexed using set item id
|
||||
private final IntIntMap skills = new IntIntMap();
|
||||
private final Array<Stat> chargedSkills = new Array<>();
|
||||
private final Attributes stats = new Attributes();
|
||||
|
||||
private static final int attack = 0;
|
||||
@ -178,11 +179,12 @@ public class CharData {
|
||||
stats.update(this); // TODO: this need to be done whenever an item is changed
|
||||
|
||||
skills.clear();
|
||||
chargedSkills.clear();
|
||||
skills.putAll(defaultSkills);
|
||||
for (int spellId = charClass.firstSpell, i = 0; spellId < charClass.lastSpell; spellId++, i++) {
|
||||
skills.put(spellId, d2s.skills.data[i]);
|
||||
}
|
||||
notifySkillsChanged(skills);
|
||||
notifySkillsChanged(skills, chargedSkills);
|
||||
}
|
||||
|
||||
public CharacterClass getCharacterClass() {
|
||||
@ -258,19 +260,20 @@ public class CharData {
|
||||
skills.put(spellId, d2s.skills.data[i]);
|
||||
}
|
||||
|
||||
chargedSkills.clear();
|
||||
for (Stat stat : stats.remaining()) {
|
||||
switch (stat.id) {
|
||||
case Stat.item_nonclassskill:
|
||||
skills.getAndIncrement(stat.param(), 0, stat.value());
|
||||
break;
|
||||
case Stat.item_charged_skill: // FIXME: This is incorrect on purpose
|
||||
skills.getAndIncrement(0xF0000000 | stat.param2(), 0, stat.param1());
|
||||
case Stat.item_charged_skill:
|
||||
chargedSkills.add(stat);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
notifySkillsChanged(skills);
|
||||
notifySkillsChanged(skills, chargedSkills);
|
||||
}
|
||||
|
||||
private void addItem(Item item) {
|
||||
@ -450,17 +453,17 @@ public class CharData {
|
||||
@Override public void onAlternated(CharData client, int alternate, Item LH, Item RH) {}
|
||||
}
|
||||
|
||||
private void notifySkillsChanged(IntIntMap skills) {
|
||||
for (SkillsListener l : SKILLS_LISTENERS) l.onChanged(this, skills);
|
||||
private void notifySkillsChanged(IntIntMap skills, Array<Stat> chargedSkills) {
|
||||
for (SkillsListener l : SKILLS_LISTENERS) l.onChanged(this, skills, chargedSkills);
|
||||
}
|
||||
|
||||
public boolean addSkillsListener(SkillsListener l) {
|
||||
SKILLS_LISTENERS.add(l);
|
||||
l.onChanged(this, skills);
|
||||
l.onChanged(this, skills, chargedSkills);
|
||||
return true;
|
||||
}
|
||||
|
||||
public interface SkillsListener {
|
||||
void onChanged(CharData client, IntIntMap skills);
|
||||
void onChanged(CharData client, IntIntMap skills, Array<Stat> chargedSkills);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.IntIntMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
@ -21,6 +22,7 @@ import com.riiablo.codec.DC6;
|
||||
import com.riiablo.codec.excel.SkillDesc;
|
||||
import com.riiablo.codec.excel.Skills;
|
||||
import com.riiablo.graphics.BlendMode;
|
||||
import com.riiablo.item.Stat;
|
||||
import com.riiablo.key.MappedKey;
|
||||
import com.riiablo.key.MappedKeyStateAdapter;
|
||||
import com.riiablo.loader.DC6Loader;
|
||||
@ -115,24 +117,22 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChanged(CharData client, IntIntMap skills) {
|
||||
public void onChanged(CharData client, IntIntMap skills, Array<Stat> chargedSkills) {
|
||||
for (Table table : tables) {
|
||||
for (Actor child : table.getChildren()) child.clear();
|
||||
table.clear();
|
||||
}
|
||||
for (IntIntMap.Entry skillId : skills) {
|
||||
if (skillId.value <= 0) continue; // level <= 0
|
||||
for (Stat chargedSkill : chargedSkills) {
|
||||
if (chargedSkill.param1() <= 0) continue; // level <= 0
|
||||
|
||||
boolean charged = (skillId.key & 0xF0000000) != 0;
|
||||
int key = skillId.key & 0x0FFFFFFF;
|
||||
final Skills.Entry skill = Riiablo.files.skills.get(key);
|
||||
final Skills.Entry skill = Riiablo.files.skills.get(chargedSkill.param2());
|
||||
if (leftSkills && !skill.leftskill) continue;
|
||||
if (skill.passive) continue;
|
||||
|
||||
final SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||
if (desc.ListRow < 0) continue;
|
||||
|
||||
int ListRow = charged ? 4 : desc.ListRow;
|
||||
int ListRow = 4;
|
||||
Table table = tables[ListRow];
|
||||
int iconCel = desc.IconCel;
|
||||
DC icons = getSkillicon(skill.charclass, iconCel);
|
||||
@ -140,12 +140,50 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
|
||||
icons = Skillicon;
|
||||
iconCel = 20;
|
||||
}
|
||||
final HotkeyButton button = new HotkeyButton(icons, iconCel, skill.Id, charged);
|
||||
final HotkeyButton button = new HotkeyButton(icons, iconCel, skill.Id, chargedSkill);
|
||||
if (skill.aura) {
|
||||
button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold);
|
||||
}
|
||||
|
||||
int index = Riiablo.charData.getHotkey(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT, key);
|
||||
int index = Riiablo.charData.getHotkey(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT, chargedSkill.param2());
|
||||
if (index != ArrayUtils.INDEX_NOT_FOUND) {
|
||||
MappedKey mapping = Keys.Skill[index];
|
||||
button.map(mapping);
|
||||
keyMappings.put(mapping, button);
|
||||
}
|
||||
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
observer.copy(button);
|
||||
SpellsQuickPanel.this.setVisible(false);
|
||||
}
|
||||
});
|
||||
table.add(button).size(SIZE);
|
||||
}
|
||||
for (IntIntMap.Entry skillId : skills) {
|
||||
if (skillId.value <= 0) continue; // level <= 0
|
||||
|
||||
final Skills.Entry skill = Riiablo.files.skills.get(skillId.key);
|
||||
if (leftSkills && !skill.leftskill) continue;
|
||||
if (skill.passive) continue;
|
||||
|
||||
final SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||
if (desc.ListRow < 0) continue;
|
||||
|
||||
Table table = tables[desc.ListRow];
|
||||
int iconCel = desc.IconCel;
|
||||
DC icons = getSkillicon(skill.charclass, iconCel);
|
||||
if (icons == null) {
|
||||
icons = Skillicon;
|
||||
iconCel = 20;
|
||||
}
|
||||
final HotkeyButton button = new HotkeyButton(icons, iconCel, skill.Id);
|
||||
if (skill.aura) {
|
||||
button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold);
|
||||
}
|
||||
|
||||
int index = Riiablo.charData.getHotkey(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT, skillId.key);
|
||||
if (index != ArrayUtils.INDEX_NOT_FOUND) {
|
||||
MappedKey mapping = Keys.Skill[index];
|
||||
button.map(mapping);
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Align;
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.DC;
|
||||
import com.riiablo.graphics.BlendMode;
|
||||
import com.riiablo.item.Stat;
|
||||
import com.riiablo.key.MappedKey;
|
||||
|
||||
public class HotkeyButton extends Button {
|
||||
@ -13,12 +14,13 @@ public class HotkeyButton extends Button {
|
||||
Label hotkey;
|
||||
Label charges;
|
||||
int skillId;
|
||||
Stat chargedSkill;
|
||||
|
||||
public HotkeyButton(final DC dc, final int index, int skillId) {
|
||||
this(dc, index, skillId, false);
|
||||
this(dc, index, skillId, null);
|
||||
}
|
||||
|
||||
public HotkeyButton(final DC dc, final int index, int skillId, boolean charged) {
|
||||
public HotkeyButton(final DC dc, final int index, int skillId, Stat chargedSkill) {
|
||||
super(new ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(dc.getTexture(index));
|
||||
down = new TextureRegionDrawable(dc.getTexture(index + 1));
|
||||
@ -27,11 +29,12 @@ public class HotkeyButton extends Button {
|
||||
}});
|
||||
|
||||
this.skillId = skillId;
|
||||
this.chargedSkill = chargedSkill;
|
||||
add(hotkey = new Label("", Riiablo.fonts.font16, Riiablo.colors.gold)).align(Align.topRight);
|
||||
row();
|
||||
add().grow();
|
||||
row();
|
||||
add(charges = new Label(charged ? "0" : "", Riiablo.fonts.font16, Riiablo.colors.blue)).align(Align.bottomLeft);
|
||||
add(charges = new Label(chargedSkill != null ? Integer.toString(chargedSkill.value1()) : "", Riiablo.fonts.font16, Riiablo.colors.blue)).align(Align.bottomLeft);
|
||||
pad(2);
|
||||
pack();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user