diff --git a/res/search.png b/res/search.png new file mode 100644 index 00000000..48bd6e6d Binary files /dev/null and b/res/search.png differ diff --git a/src/itdelatrisu/opsu/ui/KineticScrolling.java b/src/itdelatrisu/opsu/ui/KineticScrolling.java index 04a20875..b373d893 100644 --- a/src/itdelatrisu/opsu/ui/KineticScrolling.java +++ b/src/itdelatrisu/opsu/ui/KineticScrolling.java @@ -115,7 +115,8 @@ public class KineticScrolling { amplitude = 0; target = position = max; } - } else if (position < min) { + } + if (position < min) { if (allowOverScroll) { scrollToPosition(min); } else { diff --git a/src/org/newdawn/slick/gui/TextField.java b/src/org/newdawn/slick/gui/TextField.java index d58610df..a989d2c4 100644 --- a/src/org/newdawn/slick/gui/TextField.java +++ b/src/org/newdawn/slick/gui/TextField.java @@ -96,7 +96,16 @@ public class TextField extends Component { } public void render(Graphics g) { - performKeyRepeat(); + if (lastKey != -1) { + if (displayContainer.input.isKeyDown(lastKey)) { + if (repeatTimer < System.currentTimeMillis()) { + repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; + keyPressed(lastKey, lastChar); + } + } else { + lastKey = -1; + } + } Rectangle oldClip = g.getClip(); g.setWorldClip(x,y,width, height); @@ -136,20 +145,6 @@ public class TextField extends Component { g.setClip(oldClip); } - public void performKeyRepeat() { - if (lastKey == -1) { - return; - } - if (!displayContainer.input.isKeyDown(lastKey)) { - lastKey = -1; - return; - } - if (repeatTimer < System.currentTimeMillis()) { - repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; - keyPressed(lastKey, lastChar); - } - } - public String getText() { return value; } diff --git a/src/yugecin/opsudance/ui/OptionsOverlay.java b/src/yugecin/opsudance/ui/OptionsOverlay.java index 43e1f733..f9808cb3 100644 --- a/src/yugecin/opsudance/ui/OptionsOverlay.java +++ b/src/yugecin/opsudance/ui/OptionsOverlay.java @@ -151,6 +151,8 @@ public class OptionsOverlay extends OverlayOpsuState { listHoverIndex = -1; searchField = new TextField(displayContainer, null, 0, 0, 0, 0); + searchField.setMaxLength(20); + scrollHandler = new KineticScrolling(); scrollHandler.setAllowOverScroll(true); } @@ -263,7 +265,7 @@ public class OptionsOverlay extends OverlayOpsuState { if (hoverOption.getType() == OptionType.NUMERIC) { tip = "(" + hoverOption.getValueString() + ") " + tip; } - UI.updateTooltip(displayContainer.renderDelta, tip, false); + UI.updateTooltip(displayContainer.renderDelta, tip, true); UI.drawTooltip(g); } } @@ -509,6 +511,7 @@ public class OptionsOverlay extends OverlayOpsuState { @Override public void hide() { + searchField.setFocused(false); acceptInput = false; SoundController.playSound(SoundEffect.MENUBACK); hideAnimationTime = animationtime; @@ -535,8 +538,6 @@ public class OptionsOverlay extends OverlayOpsuState { scrollHandler.update(delta); - searchField.performKeyRepeat(); - updateShowHideAnimation(delta); if (animationtime <= 0) { active = false;