From 7ed4f059d578ab67cdcd36709e15170f337bef05 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 30 Mar 2019 01:00:09 -0700 Subject: [PATCH] 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 --- core/src/com/riiablo/Files.java | 2 +- core/src/com/riiablo/entity/Object.java | 2 + core/src/com/riiablo/panel/WaygatePanel.java | 174 ++++++++++++++++++ core/src/com/riiablo/screen/GameScreen.java | 15 +- .../com/riiablo/widget/IconTextButton.java | 27 +++ 5 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 core/src/com/riiablo/panel/WaygatePanel.java create mode 100644 core/src/com/riiablo/widget/IconTextButton.java diff --git a/core/src/com/riiablo/Files.java b/core/src/com/riiablo/Files.java index 4f3163df..51fbc402 100644 --- a/core/src/com/riiablo/Files.java +++ b/core/src/com/riiablo/Files.java @@ -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); diff --git a/core/src/com/riiablo/entity/Object.java b/core/src/com/riiablo/entity/Object.java index d250268a..852385ea 100644 --- a/core/src/com/riiablo/entity/Object.java +++ b/core/src/com/riiablo/entity/Object.java @@ -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: diff --git a/core/src/com/riiablo/panel/WaygatePanel.java b/core/src/com/riiablo/panel/WaygatePanel.java new file mode 100644 index 00000000..c5e9e0fc --- /dev/null +++ b/core/src/com/riiablo/panel/WaygatePanel.java @@ -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 waygatebackgroundDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\waygatebackground.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE); + TextureRegion waygatebackground; + + final AssetDescriptor expwaygatetabsDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\expwaygatetabs.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE); + DC expwaygatetabs; + + final AssetDescriptor waygateiconsDescriptor = new AssetDescriptor<>("data\\global\\ui\\MENU\\waygateicons.dc6", DC6.class, DC6Loader.DC6Parameters.COMBINE); + DC waygateicons; + Button.ButtonStyle waygateButtonStyle; + + final AssetDescriptor 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[] 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 waypoint : waypoints) { + waypoint.sort(new Comparator() { + @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