Added waypoints panel

Added waypoints panel
Created IconTextButton which acts like a Button with a LabelButton next to it
Waypoint entity will open waypoints panel when selected
Fixed issue in Files where Levels was not flagged as having the Expansion row
This commit is contained in:
Collin Smith 2019-03-30 01:00:09 -07:00
parent 882286b3ea
commit 7ed4f059d5
5 changed files with 213 additions and 7 deletions

View File

@ -111,7 +111,7 @@ public class Files {
inventory = load(assets, Inventory.class);
ItemStatCost = load(assets, ItemStatCost.class);
ItemTypes = load(assets, ItemTypes.class);
Levels = load(assets, Levels.class);
Levels = load(assets, Levels.class, Excel.EXPANSION);
LowQualityItems = load(assets, LowQualityItems.class);
LvlPrest = load(assets, LvlPrest.class);
LvlTypes = load(assets, LvlTypes.class);

View File

@ -160,6 +160,8 @@ public class Object extends Entity {
if (mode == MODE_NU) {
sequence(MODE_OP, MODE_ON);
Riiablo.audio.play("object_waypoint_open", true);
} else {
gameScreen.waygatePanel.setVisible(true);
}
break;
case 24: case 25: case 26: case 27: case 28: case 29:

View File

@ -0,0 +1,174 @@
package com.riiablo.panel;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
import com.riiablo.Riiablo;
import com.riiablo.codec.DC;
import com.riiablo.codec.DC6;
import com.riiablo.codec.excel.Levels;
import com.riiablo.graphics.BlendMode;
import com.riiablo.loader.DC6Loader;
import com.riiablo.screen.GameScreen;
import com.riiablo.widget.Button;
import com.riiablo.widget.IconTextButton;
import java.util.Comparator;
public class WaygatePanel extends WidgetGroup implements Disposable {
private static final String TAG = "WaygatePanel";
final AssetDescriptor<DC6> waygatebackgroundDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\waygatebackground.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
TextureRegion waygatebackground;
final AssetDescriptor<DC6> expwaygatetabsDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\expwaygatetabs.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
DC expwaygatetabs;
final AssetDescriptor<DC6> waygateiconsDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\waygateicons.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
DC waygateicons;
Button.ButtonStyle waygateButtonStyle;
final AssetDescriptor<DC6> buysellbtnDescriptor = new AssetDescriptor<>("data\\global\\ui\\PANEL\\buysellbtn.DC6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
Button btnExit;
final GameScreen gameScreen;
public WaygatePanel(final GameScreen gameScreen) {
this.gameScreen = gameScreen;
Riiablo.assets.load(waygatebackgroundDescriptor);
Riiablo.assets.finishLoadingAsset(waygatebackgroundDescriptor);
waygatebackground = Riiablo.assets.get(waygatebackgroundDescriptor).getTexture();
setSize(waygatebackground.getRegionWidth(), waygatebackground.getRegionHeight());
setTouchable(Touchable.enabled);
setVisible(false);
btnExit = new Button(new Button.ButtonStyle() {{
Riiablo.assets.load(buysellbtnDescriptor);
Riiablo.assets.finishLoadingAsset(buysellbtnDescriptor);
up = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(10));
down = new TextureRegionDrawable(Riiablo.assets.get(buysellbtnDescriptor).getTexture(11));
}});
btnExit.setPosition(272, 14);
btnExit.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setVisible(false);
}
});
addActor(btnExit);
Riiablo.assets.load(expwaygatetabsDescriptor);
Riiablo.assets.finishLoadingAsset(expwaygatetabsDescriptor);
expwaygatetabs = Riiablo.assets.get(expwaygatetabsDescriptor);
Riiablo.assets.load(waygateiconsDescriptor);
Riiablo.assets.finishLoadingAsset(waygateiconsDescriptor);
waygateicons = Riiablo.assets.get(waygateiconsDescriptor);
waygateButtonStyle = new Button.ButtonStyle() {{
disabled = new TextureRegionDrawable(waygateicons.getTexture(0));
up = new TextureRegionDrawable(waygateicons.getTexture(3));
down = new TextureRegionDrawable(waygateicons.getTexture(4));
}};
Array<Levels.Entry>[] waypoints = new Array[5];
for (int i = 0; i < waypoints.length; i++) waypoints[i] = new Array<>(9);
for (Levels.Entry level : Riiablo.files.Levels) {
if (level.Waypoint != 0xFF) {
waypoints[level.Act].add(level);
}
}
for (Array<Levels.Entry> waypoint : waypoints) {
waypoint.sort(new Comparator<Levels.Entry>() {
@Override
public int compare(Levels.Entry o1, Levels.Entry o2) {
return o1.Waypoint - o2.Waypoint;
}
});
}
final Tab[] tabs = new Tab[5];
for (int i = 0; i < tabs.length; i++) {
Tab tab = tabs[i] = new Tab();
for (Levels.Entry entry : waypoints[i]) {
tab.addWaypoint(entry.LevelName);
}
tab.pack();
tab.setWidth(290);
tab.layout();
//tab.setDebug(true, true);
tab.setPosition(16, getHeight() - 58, Align.topLeft);
tab.setVisible(false);
addActor(tab);
}
float x = 2, y = getHeight() - 3;
Button[] actors = new Button[5];
for (int i = 0; i < actors.length; i++) {
final int j = i << 1;
final Button actor = actors[i] = new Button(new Button.ButtonStyle() {{
down = new TextureRegionDrawable(expwaygatetabs.getTexture(j));
up = new TextureRegionDrawable(expwaygatetabs.getTexture(j + 1));
checked = down;
}});
actor.setHighlightedBlendMode(BlendMode.ID, Color.WHITE);
actor.setPosition(x, y, Align.topLeft);
actor.setUserObject(tabs[i]);
actor.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
for (Tab tab : tabs) if (tab != null) tab.setVisible(false);
Tab tab = (Tab) actor.getUserObject();
tab.setVisible(true);
}
});
addActor(actor);
x += actor.getWidth();
}
ButtonGroup<Button> tabGroup = new ButtonGroup<>();
tabGroup.add(actors);
tabGroup.setMinCheckCount(1);
tabGroup.setMaxCheckCount(1);
tabs[0].setVisible(true);
//setDebug(true, true);
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(waygatebackground, getX(), getY());
super.draw(batch, parentAlpha);
}
@Override
public void dispose() {
Riiablo.assets.unload(waygatebackgroundDescriptor.fileName);
Riiablo.assets.unload(waygateiconsDescriptor.fileName);
Riiablo.assets.unload(expwaygatetabsDescriptor.fileName);
Riiablo.assets.unload(buysellbtnDescriptor.fileName);
}
private class Tab extends Table {
Tab() {
columnDefaults(0).height(32).spaceBottom(4).growX();
}
void addWaypoint(String descId) {
add(new IconTextButton(waygateButtonStyle, Riiablo.string.lookup(descId), Riiablo.fonts.font16)).row();
}
}
}

View File

@ -58,6 +58,7 @@ import com.riiablo.panel.MobilePanel;
import com.riiablo.panel.SpellsPanel;
import com.riiablo.panel.SpellsQuickPanel;
import com.riiablo.panel.StashPanel;
import com.riiablo.panel.WaygatePanel;
import com.riiablo.server.Connect;
import com.riiablo.server.ConnectResponse;
import com.riiablo.server.Disconnect;
@ -103,6 +104,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
public CharacterPanel characterPanel;
public SpellsPanel spellsPanel;
public StashPanel stashPanel;
public WaygatePanel waygatePanel;
public SpellsQuickPanel spellsQuickPanelL;
public SpellsQuickPanel spellsQuickPanelR;
MappedKeyStateAdapter mappedKeyStateListener;
@ -234,14 +236,13 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
stage.getHeight() - spellsPanel.getHeight());
characterPanel = new CharacterPanel(this);
characterPanel.setPosition(
0,
stage.getHeight() - characterPanel.getHeight());
characterPanel.setPosition(0, stage.getHeight() - characterPanel.getHeight());
stashPanel = new StashPanel(this);
stashPanel.setPosition(
0,
stage.getHeight() - stashPanel.getHeight());
stashPanel.setPosition(0, stage.getHeight() - stashPanel.getHeight());
waygatePanel = new WaygatePanel(this);
waygatePanel.setPosition(0, stage.getHeight() - waygatePanel.getHeight());
spellsQuickPanelL = new SpellsQuickPanel(this, controlPanel.getLeftSkill(), true);
spellsQuickPanelL.setPosition(0, 100, Align.bottomLeft);
@ -262,6 +263,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
stage.addActor(spellsPanel);
stage.addActor(characterPanel);
stage.addActor(stashPanel);
stage.addActor(waygatePanel);
stage.addActor(spellsQuickPanelL);
stage.addActor(spellsQuickPanelR);
controlPanel.toFront();
@ -501,6 +503,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
}
}
} else {
// FIXME: mapListener should update when not hit, but only for non-movement events?
stage.screenToStageCoordinates(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY()));
Actor hit = stage.hit(tmpVec2.x, tmpVec2.y, true);
if (hit == null) {

View File

@ -0,0 +1,27 @@
package com.riiablo.widget;
import com.badlogic.gdx.scenes.scene2d.Event;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.riiablo.codec.FontTBL;
public class IconTextButton extends Table {
final Button button;
final LabelButton label;
public IconTextButton(Button.ButtonStyle style, String text, FontTBL.BitmapFont font) {
add(button = new Button(style)).fill(false).pad(2).padLeft(1).padTop(3);
add(label = new LabelButton(text, font)).grow().spaceLeft(25).row();
setTouchable(Touchable.enabled);
addListener(new InputListener() {
@Override
public boolean handle(Event e) {
button.getClickListener().handle(e);
label.clickListener.handle(e);
return true;
}
});
}
}