diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-24 10:23:28 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-24 10:23:28 +0100 |
commit | 11229ba16de518d0a4f80dfc4a57eb167840a344 (patch) | |
tree | c5613f1624c1b691a0b3bee1f7cc0d4695af32cb /core | |
parent | 75f72498a57a07c7b855901ebbcabdfb5781e567 (diff) | |
download | RustAndDust-11229ba16de518d0a4f80dfc4a57eb167840a344.zip RustAndDust-11229ba16de518d0a4f80dfc4a57eb167840a344.tar.gz |
PlayMenu: base rect size on list needs and screen dimension
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/PlayMenu.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java index 4922023..87eb44b 100644 --- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java @@ -1,5 +1,6 @@ package ch.asynk.rustanddust.menu; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.Batch; import ch.asynk.rustanddust.ui.Bg; @@ -36,6 +37,7 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel this.title = new Label(game.font); this.title.write("- Play"); this.list = new Scrollable(new List(game, 10f), game.framePatch); + this.padding = PADDING; } private List getList() @@ -79,13 +81,15 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel public void computePosition() { float h = (title.getHeight() + TITLE_PADDING); - h += list.getHeight(); - h += (2 * PADDING); + h += list.getBestHeight(); + h += (2 * padding); + h = Math.min(h, Gdx.graphics.getHeight() - 60); float w = title.getWidth(); if (list.getWidth() > w) w = list.getWidth(); if (list.getBestWidth() > w) w = list.getBestWidth(); - w += (2 * PADDING); + w += (2 * padding); + w = Math.min(w, Gdx.graphics.getWidth() - 60); float x = position.getX(w); float y = position.getY(h); @@ -99,11 +103,10 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel deleteBtn.visible = false; resumeBtn.visible = false; - y += PADDING; - x += PADDING; + y += padding; + x += padding; - // FIXME 200 should be relative to screen dimensions - list.setPosition(x, y, Math.max(200, list.getBestWidth()), 200); + list.setPosition(x, y, (getWidth() - 2 * padding), (getHeight() - 2 * padding - TITLE_PADDING - title.getHeight())); y += list.getHeight() + TITLE_PADDING; title.setPosition(x, y); |