diff --git a/core/src/com/riiablo/panel/ControlPanel.java b/core/src/com/riiablo/panel/ControlPanel.java index f1b99fcd..4a19e6a5 100644 --- a/core/src/com/riiablo/panel/ControlPanel.java +++ b/core/src/com/riiablo/panel/ControlPanel.java @@ -67,14 +67,20 @@ public class ControlPanel extends Table implements Disposable { manaWidget = new ManaWidget(ctrlpnl.getTexture(numFrames - 2)); if (!DEBUG_MOBILE && Gdx.app.getType() == Application.ApplicationType.Desktop) { - leftSkill = new HotkeyButton(Skillicon, 0); + leftSkill = new HotkeyButton(Skillicon, 0, -1); leftSkill.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { gameScreen.spellsQuickPanelL.setVisible(!gameScreen.spellsQuickPanelL.isVisible()); } }); - rightSkill = new HotkeyButton(Skillicon, 0); + + int leftSkillId = gameScreen.player.actions[0][0]; + if (leftSkillId > 0) { + + } + + rightSkill = new HotkeyButton(Skillicon, 0, -1); rightSkill.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -82,6 +88,11 @@ public class ControlPanel extends Table implements Disposable { } }); + int rightSkillId = gameScreen.player.actions[0][1]; + if (rightSkillId > 0) { + + } + int width = 0; int height = Integer.MIN_VALUE; for (int i = 1; i < numFrames - 2; i++) { diff --git a/core/src/com/riiablo/panel/MobileControls.java b/core/src/com/riiablo/panel/MobileControls.java index 59adc011..1f965e66 100644 --- a/core/src/com/riiablo/panel/MobileControls.java +++ b/core/src/com/riiablo/panel/MobileControls.java @@ -65,13 +65,13 @@ public class MobileControls extends WidgetGroup implements Disposable { }); skills = new HotkeyButton[3]; - skills[0] = new HotkeyButton(Skillicon, 0); + skills[0] = new HotkeyButton(Skillicon, 0, -1); skills[0].setSize(SIZE, SIZE); - skills[1] = new HotkeyButton(Skillicon, 0); + skills[1] = new HotkeyButton(Skillicon, 0, -1); skills[1].setSize(SIZE, SIZE); - skills[2] = new HotkeyButton(Skillicon, 0); + skills[2] = new HotkeyButton(Skillicon, 0, -1); skills[2].setSize(SIZE, SIZE); ActorGestureListener gestureListener = new ActorGestureListener() { @@ -96,6 +96,8 @@ public class MobileControls extends WidgetGroup implements Disposable { @Override public void tap(InputEvent event, float x, float y, int count, int button) { gameScreen.spellsQuickPanelR.setVisible(false); + Button actor = (Button) event.getListenerActor(); + // TODO: cast spell } }; gestureListener.getGestureDetector().setLongPressSeconds(0.5f); diff --git a/core/src/com/riiablo/panel/SpellsQuickPanel.java b/core/src/com/riiablo/panel/SpellsQuickPanel.java index 1046fec5..93038d4c 100644 --- a/core/src/com/riiablo/panel/SpellsQuickPanel.java +++ b/core/src/com/riiablo/panel/SpellsQuickPanel.java @@ -77,8 +77,8 @@ public class SpellsQuickPanel extends Table implements Disposable { CharacterClass charClass = player.charClass; keyMappings = new ObjectMap<>(31); Table top = new Table() {{ - add(new HotkeyButton(Skillicon, 14)); - add(new HotkeyButton(Skillicon, 18)); + add(new HotkeyButton(Skillicon, 14, -1)); + add(new HotkeyButton(Skillicon, 18, -1)); pack(); }}; Table[] tables = new Table[5]; @@ -99,7 +99,7 @@ public class SpellsQuickPanel extends Table implements Disposable { icons = Skillicon; iconCel = 20; } - final HotkeyButton button = new HotkeyButton(icons, iconCel); + final HotkeyButton button = new HotkeyButton(icons, iconCel, skill.Id); if (skill.aura) { button.setBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenGold); } @@ -121,9 +121,9 @@ public class SpellsQuickPanel extends Table implements Disposable { table.add(button); } Table bottom = new Table() {{ - add(new HotkeyButton(Skillicon, 4)); - add(new HotkeyButton(Skillicon, 6)); - add(new HotkeyButton(Skillicon, 2)); + add(new HotkeyButton(Skillicon, 4, -1)); + add(new HotkeyButton(Skillicon, 6, -1)); + add(new HotkeyButton(Skillicon, 2, -1)); pack(); }}; add(top).align(leftSkills ? Align.left : Align.right).row(); diff --git a/core/src/com/riiablo/screen/GameScreen.java b/core/src/com/riiablo/screen/GameScreen.java index 0f8923d5..520d3b1a 100644 --- a/core/src/com/riiablo/screen/GameScreen.java +++ b/core/src/com/riiablo/screen/GameScreen.java @@ -66,6 +66,7 @@ import com.riiablo.server.Packet; import com.riiablo.server.Packets; import com.riiablo.server.PipedSocket; import com.riiablo.widget.DCWrapper; +import com.riiablo.widget.HotkeyButton; import com.riiablo.widget.NpcDialogBox; import com.riiablo.widget.NpcMenu; import com.riiablo.widget.TextArea; @@ -507,20 +508,17 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable mapListener.update(); //} - if (Gdx.input.isKeyPressed(Input.Keys.F1) || Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { + if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { mapRenderer.unproject(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY())); player.lookAt(tmpVec2.x, tmpVec2.y); - boolean cast = player.cast(54); - if (cast) { + HotkeyButton rightSkill = controlPanel.getRightSkill(); + boolean cast = player.cast(rightSkill.getSkill()); + if (cast && rightSkill.getSkill() == 54) { GridPoint2 dst = mapRenderer.coords(tmpVec2.x, tmpVec2.y); player.position().set(dst.x, dst.y); player.target().setZero(); player.setPath(null, null); } - } else if (Gdx.input.isKeyPressed(Input.Keys.F2)) { - mapRenderer.unproject(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY())); - player.lookAt(tmpVec2.x, tmpVec2.y); - boolean cast = player.cast(36); } } else if (DEBUG_HIT) Gdx.app.debug(TAG, hit.toString()); diff --git a/core/src/com/riiablo/widget/HotkeyButton.java b/core/src/com/riiablo/widget/HotkeyButton.java index ab9d9259..c980fb22 100644 --- a/core/src/com/riiablo/widget/HotkeyButton.java +++ b/core/src/com/riiablo/widget/HotkeyButton.java @@ -11,8 +11,9 @@ import com.riiablo.key.MappedKey; public class HotkeyButton extends Button { MappedKey mapping; Label label; + int skillId; - public HotkeyButton(final DC dc, final int index) { + public HotkeyButton(final DC dc, final int index, int skillId) { super(new ButtonStyle() {{ up = new TextureRegionDrawable(dc.getTexture(index)); down = new TextureRegionDrawable(dc.getTexture(index + 1)); @@ -20,6 +21,7 @@ public class HotkeyButton extends Button { pressedOffsetX = pressedOffsetY = -2; }}); + this.skillId = skillId; add(label = new Label("", Riiablo.fonts.font16, Riiablo.colors.gold)); align(Align.topRight); pad(2); @@ -37,11 +39,16 @@ public class HotkeyButton extends Button { return mapping; } + public int getSkill() { + return skillId; + } + public void copy(HotkeyButton other) { setStyle(other.getStyle()); setBlendMode(other.blendMode, other.color); setDisabledBlendMode(other.disabledBlendMode, other.disabledColor); setHighlightedBlendMode(other.highlightedBlendMode, other.highlightedColor); label.setText(other.label.getText()); + skillId = other.skillId; } }