mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-07 00:39:13 +07:00
Interacting with NPC menus will now show the vendor panel
Interacting with NPC menus will now show the vendor panel Added support for configuring panel buttons using flags Added blank buttons for each vendor action (even if unused)
This commit is contained in:
@ -1,12 +1,18 @@
|
||||
package com.riiablo.ai;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
import net.mostlyoriginal.api.event.common.EventSystem;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.IntSet;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.audio.Audio;
|
||||
import com.riiablo.codec.excel.MonStats;
|
||||
@ -18,14 +24,10 @@ import com.riiablo.engine.server.component.PathWrapper;
|
||||
import com.riiablo.engine.server.component.Pathfind;
|
||||
import com.riiablo.engine.server.event.NpcInteractionEvent;
|
||||
import com.riiablo.map.DS1;
|
||||
import com.riiablo.screen.panel.VendorPanel;
|
||||
import com.riiablo.widget.NpcDialogBox;
|
||||
import com.riiablo.widget.NpcMenu;
|
||||
|
||||
import net.mostlyoriginal.api.event.common.EventSystem;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class Npc extends AI {
|
||||
private static final String TAG = "Npc";
|
||||
|
||||
@ -111,13 +113,25 @@ public class Npc extends AI {
|
||||
}
|
||||
|
||||
if (REPAIRERS.contains(entType)) {
|
||||
menu.addItem(3334, new ClickListener()); // trade/repair
|
||||
menu.addItem(3334, new ClickListener() { // trade/repair
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
Riiablo.game.vendorPanel.config(VendorPanel.SMITHY);
|
||||
Riiablo.game.setLeftPanel(Riiablo.game.vendorPanel);
|
||||
}
|
||||
});
|
||||
} else if (TRADERS.contains(entType)) {
|
||||
menu.addItem(3396, new ClickListener()); // trade
|
||||
menu.addItem(3396, new ClickListener() { // trade
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
Riiablo.game.vendorPanel.config(VendorPanel.TRADER);
|
||||
Riiablo.game.setLeftPanel(Riiablo.game.vendorPanel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (HIRERERS.contains(entType)) {
|
||||
menu.addItem(3397, new ClickListener()); // gamble
|
||||
menu.addItem(3397, new ClickListener()); // hire
|
||||
}
|
||||
|
||||
if (GAMBLERS.contains(entType)) {
|
||||
|
@ -25,6 +25,24 @@ import com.riiablo.widget.LabelButton;
|
||||
public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
private static final String TAG = "VendorPanel";
|
||||
|
||||
public static final int BUY = 1 << 0;
|
||||
public static final int SELL = 1 << 1;
|
||||
public static final int REPAIR = 1 << 2;
|
||||
public static final int REPAIR_ALL = 1 << 4;
|
||||
public static final int EXIT = 1 << 5;
|
||||
|
||||
public static final int BUYSELL = BUY | SELL;
|
||||
public static final int REPAIRER = REPAIR | REPAIR_ALL;
|
||||
public static final int TRADER = BUYSELL | EXIT;
|
||||
public static final int SMITHY = BUYSELL | REPAIRER;
|
||||
|
||||
static final int BLANK_MASKS[] = {
|
||||
BUY,
|
||||
SELL,
|
||||
REPAIR,
|
||||
EXIT | REPAIR_ALL
|
||||
};
|
||||
|
||||
final AssetDescriptor<DC6> buysellDescriptor = new AssetDescriptor<>("data\\global\\ui\\PANEL\\buysell.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
|
||||
TextureRegion buysell;
|
||||
|
||||
@ -35,8 +53,9 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
Button btnBuy;
|
||||
Button btnSell;
|
||||
Button btnRepair;
|
||||
Button btnBlank;
|
||||
Button btnRepairAll;
|
||||
Button btnExit;
|
||||
Button btnBlank[];
|
||||
|
||||
Tab[] tabs;
|
||||
|
||||
@ -84,33 +103,39 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
addActor(label);
|
||||
}
|
||||
|
||||
Riiablo.assets.load(buysellbtnDescriptor);
|
||||
Riiablo.assets.finishLoadingAsset(buysellbtnDescriptor);
|
||||
btnExit = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(10));
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(11));
|
||||
}});
|
||||
btnExit.setPosition(272, 15);
|
||||
btnExit.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
addActor(btnExit);
|
||||
final float[] X = {116, 168, 220, 272};
|
||||
Button.ButtonStyle blankButtonStyle = new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(0));
|
||||
}};
|
||||
btnBlank = new Button[4];
|
||||
for (int i = 0; i < btnBlank.length; i++) {
|
||||
Button button = btnBlank[i] = new Button(blankButtonStyle);
|
||||
button.setDisabledBlendMode(BlendMode.NONE, Riiablo.colors.white);
|
||||
button.setDisabled(true);
|
||||
button.setPosition(X[i], 15);
|
||||
button.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
||||
}
|
||||
});
|
||||
button.setVisible(false);
|
||||
addActor(button);
|
||||
}
|
||||
|
||||
btnBuy = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(2));
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(3));
|
||||
checked = down;
|
||||
}});
|
||||
btnBuy.setPosition(116, 15);
|
||||
btnBuy.setPosition(btnBlank[0].getX(), btnBlank[0].getY());
|
||||
btnBuy.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
||||
}
|
||||
});
|
||||
btnBuy.setVisible(false);
|
||||
addActor(btnBuy);
|
||||
|
||||
btnSell = new Button(new Button.ButtonStyle() {{
|
||||
@ -118,34 +143,21 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(5));
|
||||
checked = down;
|
||||
}});
|
||||
btnSell.setPosition(168, 15);
|
||||
btnSell.setPosition(btnBlank[1].getX(), btnBlank[1].getY());
|
||||
btnSell.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
||||
}
|
||||
});
|
||||
btnSell.setVisible(false);
|
||||
addActor(btnSell);
|
||||
|
||||
btnBlank = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(0));
|
||||
}});
|
||||
btnBlank.setDisabledBlendMode(BlendMode.NONE, Riiablo.colors.white);
|
||||
btnBlank.setDisabled(true);
|
||||
btnBlank.setPosition(220, 15);
|
||||
btnBlank.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
||||
}
|
||||
});
|
||||
addActor(btnBlank);
|
||||
|
||||
btnRepair = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(6));
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(7));
|
||||
}});
|
||||
btnRepair.setPosition(220, 15);
|
||||
btnRepair.setPosition(btnBlank[2].getX(), btnBlank[2].getY());
|
||||
btnRepair.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
@ -155,6 +167,36 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
btnRepair.setVisible(false);
|
||||
addActor(btnRepair);
|
||||
|
||||
btnRepairAll = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(18));
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(19));
|
||||
}});
|
||||
btnRepairAll.setPosition(btnBlank[3].getX(), btnBlank[3].getY());
|
||||
btnRepairAll.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
|
||||
}
|
||||
});
|
||||
btnRepairAll.setVisible(false);
|
||||
addActor(btnRepairAll);
|
||||
|
||||
Riiablo.assets.load(buysellbtnDescriptor);
|
||||
Riiablo.assets.finishLoadingAsset(buysellbtnDescriptor);
|
||||
btnExit = new Button(new Button.ButtonStyle() {{
|
||||
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(10));
|
||||
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(11));
|
||||
}});
|
||||
btnExit.setPosition(btnBlank[3].getX(), btnBlank[3].getY());
|
||||
btnExit.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
btnExit.setVisible(false);
|
||||
addActor(btnExit);
|
||||
|
||||
Label goldbankLabel = Label.i18n("stash", Riiablo.fonts.font16);
|
||||
goldbankLabel.setSize(180, 16);
|
||||
goldbankLabel.setPosition(20, 57);
|
||||
@ -179,11 +221,12 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
btnExit.dispose();
|
||||
btnBuy.dispose();
|
||||
btnSell.dispose();
|
||||
btnRepair.dispose();
|
||||
btnBlank.dispose();
|
||||
btnRepairAll.dispose();
|
||||
btnExit.dispose();
|
||||
for (int i = 0; i < btnBlank.length; i++) btnBlank[i].dispose();
|
||||
Riiablo.assets.unload(buysellDescriptor.fileName);
|
||||
Riiablo.assets.unload(buyselltabsDescriptor.fileName);
|
||||
Riiablo.assets.unload(buysellbtnDescriptor.fileName);
|
||||
@ -203,6 +246,17 @@ public class VendorPanel extends WidgetGroup implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public void config(int flags) {
|
||||
btnBuy.setVisible((flags & BUY) == BUY);
|
||||
btnSell.setVisible((flags & SELL) == SELL);
|
||||
btnRepair.setVisible((flags & REPAIR) == REPAIR);
|
||||
btnRepairAll.setVisible((flags & REPAIR_ALL) == REPAIR_ALL);
|
||||
btnExit.setVisible((flags & EXIT) == EXIT);
|
||||
for (int i = 0; i < btnBlank.length; i++) {
|
||||
btnBlank[i].setVisible((flags & BLANK_MASKS[i]) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Tab extends WidgetGroup {
|
||||
static final int ACTIVE = 0;
|
||||
static final int INACTIVE = 1;
|
||||
|
Reference in New Issue
Block a user