make the menu respond better (for slider values etc)

This commit is contained in:
yugecin 2016-11-12 23:34:45 +01:00
parent a3659d7a7d
commit 1cb815360c

View File

@ -207,6 +207,7 @@ public class OptionsMenu extends BasicGameState {
private Input input; private Input input;
private Graphics g; private Graphics g;
private final int state; private final int state;
private GameOption selectedOption;
private final ItemList list; private final ItemList list;
private final RWM rwm; private final RWM rwm;
@ -268,6 +269,9 @@ public class OptionsMenu extends BasicGameState {
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT : GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
(keyEntryRight) ? GameOption.KEY_RIGHT : (keyEntryRight) ? GameOption.KEY_RIGHT :
getOptionAt(mouseY); getOptionAt(mouseY);
if (selectedOption != null) {
hoverOption = selectedOption;
}
for (int i = 0; i < currentTab.options.length; i++) { for (int i = 0; i < currentTab.options.length; i++) {
GameOption option = currentTab.options[i]; GameOption option = currentTab.options[i];
drawOption(option, i, hoverOption == option); drawOption(option, i, hoverOption == option);
@ -335,6 +339,7 @@ public class OptionsMenu extends BasicGameState {
@Override @Override
public void mouseReleased(int button, int x, int y) { public void mouseReleased(int button, int x, int y) {
selectedOption = null;
if (list.isVisible()) { if (list.isVisible()) {
list.mouseReleased(button, x, y); list.mouseReleased(button, x, y);
} }
@ -384,6 +389,7 @@ public class OptionsMenu extends BasicGameState {
// options (click only) // options (click only)
final GameOption option = getOptionAt(y); final GameOption option = getOptionAt(y);
if (option != null) { if (option != null) {
selectedOption = option;
Object[] listItems = option.getListItems(); Object[] listItems = option.getListItems();
if (listItems == null) { if (listItems == null) {
if (option.showRWM()) { if (option.showRWM()) {
@ -443,9 +449,9 @@ public class OptionsMenu extends BasicGameState {
diff = ((diff > 0) ? 1 : -1) * multiplier; diff = ((diff > 0) ? 1 : -1) * multiplier;
// options (drag only) // options (drag only)
GameOption option = getOptionAt(oldy); if (selectedOption != null) {
if (option != null) selectedOption.drag(container, diff);
option.drag(container, diff); }
} }
@Override @Override