From abde0c9fdc4634f0789df84c75f36786e68f6f31 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Tue, 12 Mar 2019 01:48:48 -0700 Subject: [PATCH] Added show ground labels for items (not selectable yet) Added button to show all labels for items on the ground Fixed issue where dropped items were overwriting existing entities -- going to replace with ashley soon --- core/src/com/riiablo/map/MapListener.java | 5 ++++- core/src/com/riiablo/screen/GameScreen.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/src/com/riiablo/map/MapListener.java b/core/src/com/riiablo/map/MapListener.java index 843ca26e..dd0122e4 100644 --- a/core/src/com/riiablo/map/MapListener.java +++ b/core/src/com/riiablo/map/MapListener.java @@ -3,6 +3,7 @@ package com.riiablo.map; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.math.GridPoint2; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Array; @@ -87,7 +88,9 @@ public class MapListener { Riiablo.cursor.setItem(null); Entity item = new ItemHolder(cursor); item.position().set(gameScreen.player.position()); - gameScreen.entities.put(gameScreen.entities.size + 1, item); + int randomId; + while (gameScreen.entities.get(randomId = MathUtils.random.nextInt(Integer.MAX_VALUE)) != null); + gameScreen.entities.put(randomId, item); requireRelease = true; return; } diff --git a/core/src/com/riiablo/screen/GameScreen.java b/core/src/com/riiablo/screen/GameScreen.java index f28d9ce5..df810d03 100644 --- a/core/src/com/riiablo/screen/GameScreen.java +++ b/core/src/com/riiablo/screen/GameScreen.java @@ -103,6 +103,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable NpcMenu menu; NpcDialogBox dialog; Actor details; + boolean showItems; public TextArea input; TextArea output; @@ -504,6 +505,23 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable details.draw(b, 1); b.end(); } + + + showItems = UIUtils.alt(); + if (showItems) { + clearLabels(); + for (Entity entity : entities.values()) { + if (entity instanceof ItemHolder) { + Actor label = entity.getLabel(); + addLabel(label); + } + } + layoutLabels(); + + b.begin(); + for (Actor label : labels) label.draw(b, 1); + b.end(); + } } @Override