summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-22 00:25:04 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-22 00:25:04 +0100
commitf3181eaa423fa9fc2b30e7d66726ccdf9e84d3c7 (patch)
tree14f1f7f023ca04e23fa5fa8117898aa735bebe9b
parenteb66123c2da40b26b9c758e0a36b1a21ae4a9611 (diff)
downloadRustAndDust-f3181eaa423fa9fc2b30e7d66726ccdf9e84d3c7.zip
RustAndDust-f3181eaa423fa9fc2b30e7d66726ccdf9e84d3c7.tar.gz
List: correctly select, add Integer getIdx()
-rw-r--r--core/src/ch/asynk/rustanddust/ui/List.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/ui/List.java b/core/src/ch/asynk/rustanddust/ui/List.java
index ef4a5f9..0d5165a 100644
--- a/core/src/ch/asynk/rustanddust/ui/List.java
+++ b/core/src/ch/asynk/rustanddust/ui/List.java
@@ -36,14 +36,19 @@ public class List extends Widget
this.selected = new Bg(game.getUiRegion(game.UI_SELECT));
}
+ public Integer getIdx() { return idx; }
+
@Override
public boolean hit(float x, float y)
{
float t = (getTop() - (int) padding);
idx = (int) Math.floor((t - y) / itemHeight);
- if ((idx >= 0) && (idx < items.size()))
+ if ((idx >= 0) && (idx < items.size())) {
selected.setPosition(rect.x, (t - itemHeight - (idx * itemHeight)), rect.width, (itemHeight + padding));
- return true;
+ return true;
+ }
+ idx = null;
+ return false;
}
public void setItems(int clipN, Collection<ListElement> items)