From 7abd0d5c63cad03bb93987f5f39dddd140283f13 Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 11 Dec 2016 02:14:43 +0100 Subject: [PATCH] clickable tabs --- src/yugecin/opsudance/ui/OptionsOverlay.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/yugecin/opsudance/ui/OptionsOverlay.java b/src/yugecin/opsudance/ui/OptionsOverlay.java index 8c0abcc6..14156f56 100644 --- a/src/yugecin/opsudance/ui/OptionsOverlay.java +++ b/src/yugecin/opsudance/ui/OptionsOverlay.java @@ -123,11 +123,14 @@ public class OptionsOverlay { private void renderOptions(Graphics g) { g.setClip(0, optionStartY, width, height - optionStartY); int y = -scrollOffset + optionStartY; + selectedTab = 0; for (int tabIndex = 0; tabIndex < tabs.length; tabIndex++) { OptionTab tab = tabs[tabIndex]; if (y > 0) { int x = optionStartX + (optionWidth - Fonts.LARGE.getWidth(tab.name)) / 2; Fonts.LARGE.drawString(x, y + Fonts.LARGE.getLineHeight() * 0.6f, tab.name, Color.cyan); + } else { + selectedTab++; } y += Fonts.MEDIUM.getLineHeight() * 2; for (int optionIndex = 0; optionIndex < tab.options.length; optionIndex++) { @@ -234,6 +237,19 @@ public class OptionsOverlay { if (hoverOption != null && hoverOption.getType() == OptionType.BOOLEAN) { hoverOption.click(container); } + + int tScrollOffset = 0; + for (int tabIndex = 0; tabIndex < tabs.length; tabIndex++) { + if (tabs[tabIndex].button.contains(x, y)) { + if (selectedTab != tabIndex) { + selectedTab = tabIndex; + scrollOffset = tScrollOffset; + } + break; + } + tScrollOffset += Fonts.MEDIUM.getLineHeight() * 2; + tScrollOffset += tabs[tabIndex].options.length * optionHeight; + } } public void mouseReleased(int button, int x, int y) {