mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-05 15:58:38 +07:00
Buy, sell and repair buttons are now managed by a button group
This commit is contained in:
@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
@ -57,6 +58,7 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
Button btnRepairAll;
|
Button btnRepairAll;
|
||||||
Button btnExit;
|
Button btnExit;
|
||||||
Button btnBlank[];
|
Button btnBlank[];
|
||||||
|
ButtonGroup<Button> buttonGroup;
|
||||||
|
|
||||||
Tab[] tabs;
|
Tab[] tabs;
|
||||||
|
|
||||||
@ -127,7 +129,7 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
btnBuy.addListener(new ClickListener() {
|
btnBuy.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
btnSell.setChecked(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnBuy.setVisible(false);
|
btnBuy.setVisible(false);
|
||||||
@ -142,7 +144,7 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
btnSell.addListener(new ClickListener() {
|
btnSell.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
btnBuy.setChecked(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnSell.setVisible(false);
|
btnSell.setVisible(false);
|
||||||
@ -151,6 +153,7 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
btnRepair = new Button(new Button.ButtonStyle() {{
|
btnRepair = new Button(new Button.ButtonStyle() {{
|
||||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(6));
|
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(6));
|
||||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(7));
|
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(7));
|
||||||
|
checked = down;
|
||||||
}});
|
}});
|
||||||
btnRepair.setPosition(btnBlank[2].getX(), btnBlank[2].getY());
|
btnRepair.setPosition(btnBlank[2].getX(), btnBlank[2].getY());
|
||||||
btnRepair.addListener(new ClickListener() {
|
btnRepair.addListener(new ClickListener() {
|
||||||
@ -192,6 +195,10 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
btnExit.setVisible(false);
|
btnExit.setVisible(false);
|
||||||
addActor(btnExit);
|
addActor(btnExit);
|
||||||
|
|
||||||
|
buttonGroup = new ButtonGroup<>();
|
||||||
|
buttonGroup.setMinCheckCount(0);
|
||||||
|
buttonGroup.add(btnBuy, btnSell, btnRepair);
|
||||||
|
|
||||||
Label goldbankLabel = Label.i18n("stash", Riiablo.fonts.font16);
|
Label goldbankLabel = Label.i18n("stash", Riiablo.fonts.font16);
|
||||||
goldbankLabel.setSize(180, 16);
|
goldbankLabel.setSize(180, 16);
|
||||||
goldbankLabel.setPosition(20, 57);
|
goldbankLabel.setPosition(20, 57);
|
||||||
@ -242,8 +249,7 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void config(int flags) {
|
public void config(int flags) {
|
||||||
btnBuy.setChecked(false);
|
buttonGroup.uncheckAll();
|
||||||
btnSell.setChecked(false);
|
|
||||||
btnBuy.setVisible((flags & BUY) == BUY);
|
btnBuy.setVisible((flags & BUY) == BUY);
|
||||||
btnSell.setVisible((flags & SELL) == SELL);
|
btnSell.setVisible((flags & SELL) == SELL);
|
||||||
btnRepair.setVisible((flags & REPAIR) == REPAIR);
|
btnRepair.setVisible((flags & REPAIR) == REPAIR);
|
||||||
|
Reference in New Issue
Block a user