Slight changes to DropdownMenu behavior.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
643a7c4589
commit
7f1193bb77
|
@ -524,8 +524,12 @@ public class DownloadsMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dropdown menu
|
// dropdown menu
|
||||||
if (serverMenu.click(x, y)) {
|
int oldServerIndex = serverMenu.getSelectedIndex(), serverMenuClickResult = serverMenu.click(x, y);
|
||||||
|
if (serverMenuClickResult > -2) {
|
||||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||||
|
if (serverMenuClickResult == -1 || serverMenuClickResult == oldServerIndex)
|
||||||
|
return;
|
||||||
|
|
||||||
resultList = null;
|
resultList = null;
|
||||||
startResult = 0;
|
startResult = 0;
|
||||||
focusResult = -1;
|
focusResult = -1;
|
||||||
|
@ -541,8 +545,6 @@ public class DownloadsMenu extends BasicGameState {
|
||||||
resetSearchTimer();
|
resetSearchTimer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (serverMenu.contains(x, y))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// search results
|
// search results
|
||||||
DownloadNode[] nodes = resultList;
|
DownloadNode[] nodes = resultList;
|
||||||
|
|
|
@ -173,6 +173,12 @@ public class DropdownMenu<E> {
|
||||||
*/
|
*/
|
||||||
public boolean isOpen() { return expanded; }
|
public boolean isOpen() { return expanded; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens or closes the dropdown menu.
|
||||||
|
* @param flag true to open, false to close
|
||||||
|
*/
|
||||||
|
public void open(boolean flag) { this.expanded = flag; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the coordinates are within the menu bounds.
|
* Returns true if the coordinates are within the menu bounds.
|
||||||
* @param cx the x coordinate
|
* @param cx the x coordinate
|
||||||
|
@ -280,35 +286,25 @@ public class DropdownMenu<E> {
|
||||||
* Registers a click at the given location.
|
* Registers a click at the given location.
|
||||||
* If the base item is clicked and the menu is unexpanded, it will be expanded;
|
* If the base item is clicked and the menu is unexpanded, it will be expanded;
|
||||||
* in all other cases, the menu will be unexpanded. If an item different from
|
* in all other cases, the menu will be unexpanded. If an item different from
|
||||||
* the current one is selected, this will select that item and return {@code true}.
|
* the current one is selected, that item will be selected.
|
||||||
* Otherwise, this will return {@code false}.
|
|
||||||
* @param cx the x coordinate
|
* @param cx the x coordinate
|
||||||
* @param cy the y coordinate
|
* @param cy the y coordinate
|
||||||
|
* @return the index of the item at the given location, -1 for the base item,
|
||||||
|
* and -2 if there is no item at the location
|
||||||
*/
|
*/
|
||||||
public boolean click(float cx, float cy) {
|
public int click(float cx, float cy) {
|
||||||
int idx = getIndexAt(cx, cy);
|
int idx = getIndexAt(cx, cy);
|
||||||
if (idx == -2) {
|
this.expanded = (idx == -1) ? !expanded : false;
|
||||||
this.expanded = false;
|
if (idx >= 0)
|
||||||
return false;
|
this.itemIndex = idx;
|
||||||
} else if (idx == -1) {
|
return idx;
|
||||||
this.expanded = !expanded;
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
this.expanded = false;
|
|
||||||
if (itemIndex == idx)
|
|
||||||
return false;
|
|
||||||
else {
|
|
||||||
itemIndex = idx;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the menu state.
|
* Resets the menu state.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
expanded = false;
|
this.expanded = false;
|
||||||
expandProgress.setTime(0);
|
expandProgress.setTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user