Created CharData#setAction(int,int) which passes current alternate id

Created CharData#setAction(int,int) which passes current alternate id
Created SpellsQuickPanel#buttonId field to store Input.Buttons.LEFT or Input.Buttons.RIGHT
This commit is contained in:
Collin Smith 2020-08-21 14:58:20 -07:00
parent 5061c10b69
commit 46bdd1f94a
2 changed files with 10 additions and 7 deletions

View File

@ -286,6 +286,10 @@ public class CharData implements ItemData.UpdateListener, Pool.Poolable {
return actions[alternate][button]; return actions[alternate][button];
} }
public void setAction(int button, int skill) {
setAction(itemData.alternate, button, skill);
}
public void setAction(int alternate, int button, int skill) { public void setAction(int alternate, int button, int skill) {
actions[alternate][button] = skill; actions[alternate][button] = skill;
} }

View File

@ -70,10 +70,12 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
final float SIZE; final float SIZE;
final int ALIGN; final int ALIGN;
IntMap<HotkeyButton> buttons; IntMap<HotkeyButton> buttons;
final int buttonId;
public SpellsQuickPanel(final HotkeyButton o, final boolean leftSkills) { public SpellsQuickPanel(final HotkeyButton o, final boolean leftSkills) {
this.observer = o; this.observer = o;
this.leftSkills = leftSkills; this.leftSkills = leftSkills;
this.buttonId = leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT;
Riiablo.assets.load(SkilliconDescriptor); Riiablo.assets.load(SkilliconDescriptor);
Riiablo.assets.finishLoadingAsset(SkilliconDescriptor); Riiablo.assets.finishLoadingAsset(SkilliconDescriptor);
@ -108,10 +110,7 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
if (button == null) return; if (button == null) return;
observer.copy(button); observer.copy(button);
// FIXME: it isn't appropriate to have this call here -- should separate into a controller // FIXME: it isn't appropriate to have this call here -- should separate into a controller
Riiablo.charData.setAction( Riiablo.charData.setAction(buttonId, button.getSkill());
Riiablo.charData.getItems().getAlternate(),
leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT,
button.getSkill());
} }
}; };
for (MappedKey Skill : Keys.Skill) Skill.addStateListener(mappedKeyListener); for (MappedKey Skill : Keys.Skill) Skill.addStateListener(mappedKeyListener);
@ -120,7 +119,7 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
Riiablo.charData.getItems().addAlternateListener(new ItemData.AlternateListener() { Riiablo.charData.getItems().addAlternateListener(new ItemData.AlternateListener() {
@Override @Override
public void onAlternated(ItemData items, int alternate, Item LH, Item RH) { public void onAlternated(ItemData items, int alternate, Item LH, Item RH) {
int skillId = Riiablo.charData.getAction(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT); int skillId = Riiablo.charData.getAction(buttonId);
HotkeyButton button = buttons.get(skillId); HotkeyButton button = buttons.get(skillId);
observer.copy(button); observer.copy(button);
} }
@ -157,7 +156,7 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold); button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold);
} }
int index = Riiablo.charData.getHotkey(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT, chargedSkill.param2()); int index = Riiablo.charData.getHotkey(buttonId, chargedSkill.param2());
if (index != ArrayUtils.INDEX_NOT_FOUND) { if (index != ArrayUtils.INDEX_NOT_FOUND) {
MappedKey mapping = Keys.Skill[index]; MappedKey mapping = Keys.Skill[index];
button.map(mapping); button.map(mapping);
@ -196,7 +195,7 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold); button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold);
} }
int index = Riiablo.charData.getHotkey(leftSkills ? Input.Buttons.LEFT : Input.Buttons.RIGHT, skillId.key); int index = Riiablo.charData.getHotkey(buttonId, skillId.key);
if (index != ArrayUtils.INDEX_NOT_FOUND) { if (index != ArrayUtils.INDEX_NOT_FOUND) {
MappedKey mapping = Keys.Skill[index]; MappedKey mapping = Keys.Skill[index];
button.map(mapping); button.map(mapping);