Implemented SpellsQuickPanel changes to MobileControls buttons

This commit is contained in:
Collin Smith 2019-03-19 20:34:44 -07:00
parent 8965238c22
commit 6734c9a614
3 changed files with 18 additions and 23 deletions

View File

@ -16,6 +16,7 @@ import com.riiablo.codec.DC6;
import com.riiablo.entity.Entity;
import com.riiablo.screen.GameScreen;
import com.riiablo.widget.Button;
import com.riiablo.widget.HotkeyButton;
public class MobileControls extends WidgetGroup implements Disposable {
final AssetDescriptor<DC6> SkilliconDescriptor = new AssetDescriptor<>("data\\global\\ui\\SPELLS\\Skillicon.DC6", DC6.class);
@ -27,7 +28,7 @@ public class MobileControls extends WidgetGroup implements Disposable {
GameScreen gameScreen;
Button interact;
Button skills[];
HotkeyButton skills[];
final float SIZE = 64;
@ -63,23 +64,14 @@ public class MobileControls extends WidgetGroup implements Disposable {
}
});
skills = new Button[3];
skills[0] = new Button(new Button.ButtonStyle() {{
up = new TextureRegionDrawable(SoSkillicon.getTexture(36));
down = new TextureRegionDrawable(SoSkillicon.getTexture(37));
}});
skills = new HotkeyButton[3];
skills[0] = new HotkeyButton(Skillicon, 0);
skills[0].setSize(SIZE, SIZE);
skills[1] = new Button(new Button.ButtonStyle() {{
up = new TextureRegionDrawable(Skillicon.getTexture(0));
down = new TextureRegionDrawable(Skillicon.getTexture(1));
}});
skills[1] = new HotkeyButton(Skillicon, 0);
skills[1].setSize(SIZE, SIZE);
skills[2] = new Button(new Button.ButtonStyle() {{
up = new TextureRegionDrawable(Skillicon.getTexture(0));
down = new TextureRegionDrawable(Skillicon.getTexture(1));
}});
skills[2] = new HotkeyButton(Skillicon, 0);
skills[2].setSize(SIZE, SIZE);
ActorGestureListener gestureListener = new ActorGestureListener() {
@ -90,6 +82,8 @@ public class MobileControls extends WidgetGroup implements Disposable {
SpellsQuickPanel spellsQuickPanel = gameScreen.spellsQuickPanelR;
final boolean visible = !spellsQuickPanel.isVisible();
if (visible) {
HotkeyButton dst = (HotkeyButton) actor;
spellsQuickPanel.setObserver(dst);
// FIXME: Scale this better
tmpVec2.set(actor.getWidth(), actor.getHeight());
actor.localToStageCoordinates(tmpVec2);

View File

@ -54,9 +54,11 @@ public class SpellsQuickPanel extends Table implements Disposable {
GameScreen gameScreen;
ObjectMap<MappedKey, HotkeyButton> keyMappings;
MappedKeyStateAdapter mappedKeyListener;
HotkeyButton observer;
public SpellsQuickPanel(final GameScreen gameScreen, final boolean leftSkills) {
public SpellsQuickPanel(final GameScreen gameScreen, final HotkeyButton o, final boolean leftSkills) {
this.gameScreen = gameScreen;
this.observer = o;
Riiablo.assets.load(SkilliconDescriptor);
Riiablo.assets.finishLoadingAsset(SkilliconDescriptor);
@ -112,12 +114,7 @@ public class SpellsQuickPanel extends Table implements Disposable {
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ControlPanel controlPanel = gameScreen.controlPanel;
if (leftSkills) {
controlPanel.getLeftSkill().copy(button);
} else {
controlPanel.getRightSkill().copy(button);
}
observer.copy(button);
SpellsQuickPanel.this.setVisible(false);
}
});
@ -156,6 +153,10 @@ public class SpellsQuickPanel extends Table implements Disposable {
for (MappedKey Skill : Keys.Skill) Skill.addStateListener(mappedKeyListener);
}
public void setObserver(HotkeyButton observer) {
this.observer = observer;
}
@Override
public void dispose() {
for (MappedKey Skill : Keys.Skill) Skill.removeStateListener(mappedKeyListener);

View File

@ -235,11 +235,11 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
0,
stage.getHeight() - stashPanel.getHeight());
spellsQuickPanelL = new SpellsQuickPanel(this, true);
spellsQuickPanelL = new SpellsQuickPanel(this, controlPanel.getLeftSkill(), true);
spellsQuickPanelL.setPosition(0, 100, Align.bottomLeft);
spellsQuickPanelL.setVisible(false);
spellsQuickPanelR = new SpellsQuickPanel(this, false);
spellsQuickPanelR = new SpellsQuickPanel(this, controlPanel.getRightSkill(), false);
spellsQuickPanelR.setPosition(stage.getWidth(), 100, Align.bottomRight);
spellsQuickPanelR.setVisible(false);