readd search field and sort menu in songmenu
This commit is contained in:
parent
e9046ed65e
commit
04449abe62
|
@ -22,7 +22,6 @@ import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.GameData.Grade;
|
import itdelatrisu.opsu.GameData.Grade;
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.Opsu;
|
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.ScoreData;
|
import itdelatrisu.opsu.ScoreData;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
|
@ -62,25 +61,16 @@ import java.nio.file.WatchEvent.Kind;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.lwjgl.opengl.Display;
|
|
||||||
import org.newdawn.slick.Animation;
|
import org.newdawn.slick.Animation;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
|
||||||
import org.newdawn.slick.SpriteSheet;
|
import org.newdawn.slick.SpriteSheet;
|
||||||
import org.newdawn.slick.gui.TextField;
|
import org.newdawn.slick.gui.TextField;
|
||||||
import org.newdawn.slick.state.StateBasedGame;
|
|
||||||
import org.newdawn.slick.state.transition.EasedFadeOutTransition;
|
|
||||||
import org.newdawn.slick.state.transition.EmptyTransition;
|
|
||||||
import org.newdawn.slick.state.transition.FadeInTransition;
|
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.events.EventListener;
|
|
||||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
import yugecin.opsudance.core.state.ComplexOpsuState;
|
||||||
import yugecin.opsudance.events.ResolutionChangedEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Song Selection" state.
|
* "Song Selection" state.
|
||||||
|
@ -88,7 +78,7 @@ import yugecin.opsudance.events.ResolutionChangedEvent;
|
||||||
* Players are able to select a beatmap to play, view previous scores, choose game mods,
|
* Players are able to select a beatmap to play, view previous scores, choose game mods,
|
||||||
* manage beatmaps, or change game options from this state.
|
* manage beatmaps, or change game options from this state.
|
||||||
*/
|
*/
|
||||||
public class SongMenu extends BaseOpsuState {
|
public class SongMenu extends ComplexOpsuState {
|
||||||
|
|
||||||
private final InstanceContainer instanceContainer;
|
private final InstanceContainer instanceContainer;
|
||||||
|
|
||||||
|
@ -176,8 +166,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
private MenuButton selectModsButton, selectRandomButton, selectMapOptionsButton, selectOptionsButton;
|
private MenuButton selectModsButton, selectRandomButton, selectMapOptionsButton, selectOptionsButton;
|
||||||
|
|
||||||
/** The search textfield. */
|
/** The search textfield. */
|
||||||
//private TextField search;
|
private TextField searchTextField;
|
||||||
// TODO d recreate textfield
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delay timer, in milliseconds, before running another search.
|
* Delay timer, in milliseconds, before running another search.
|
||||||
|
@ -238,7 +227,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
} finally {
|
} finally {
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/** Reloads all beatmaps. */
|
/** Reloads all beatmaps. */
|
||||||
private void reloadBeatmaps() {
|
private void reloadBeatmaps() {
|
||||||
|
@ -329,8 +318,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
private boolean isScrollingToFocusNode = false;
|
private boolean isScrollingToFocusNode = false;
|
||||||
|
|
||||||
/** Sort order dropdown menu. */
|
/** Sort order dropdown menu. */
|
||||||
// TODO: d remake dropdownmenu
|
private DropdownMenu<BeatmapSortOrder> sortMenu;
|
||||||
//private DropdownMenu<BeatmapSortOrder> sortMenu;
|
|
||||||
|
|
||||||
public SongMenu(final DisplayContainer displayContainer, InstanceContainer instanceContainer) {
|
public SongMenu(final DisplayContainer displayContainer, InstanceContainer instanceContainer) {
|
||||||
super(displayContainer);
|
super(displayContainer);
|
||||||
|
@ -357,11 +345,10 @@ public class SongMenu extends BaseOpsuState {
|
||||||
footerLogoButton.setHoverExpand(1.2f);
|
footerLogoButton.setHoverExpand(1.2f);
|
||||||
|
|
||||||
// initialize sorts
|
// initialize sorts
|
||||||
// TODO d reenable dropdown
|
|
||||||
/*
|
|
||||||
int sortWidth = (int) (displayContainer.width * 0.12f);
|
int sortWidth = (int) (displayContainer.width * 0.12f);
|
||||||
sortMenu = new DropdownMenu<BeatmapSortOrder>(container, BeatmapSortOrder.values(),
|
int posX = (int) (displayContainer.width * 0.87f);
|
||||||
displayContainer.width * 0.87f, headerY - GameImage.MENU_TAB.getImage().getHeight() * 2.25f, sortWidth) {
|
int posY = (int) (headerY - GameImage.MENU_TAB.getImage().getHeight() * 2.25f);
|
||||||
|
sortMenu = new DropdownMenu<BeatmapSortOrder>(displayContainer, BeatmapSortOrder.values(), posX, posY, sortWidth) {
|
||||||
@Override
|
@Override
|
||||||
public void itemSelected(int index, BeatmapSortOrder item) {
|
public void itemSelected(int index, BeatmapSortOrder item) {
|
||||||
BeatmapSortOrder.set(item);
|
BeatmapSortOrder.set(item);
|
||||||
|
@ -375,7 +362,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean menuClicked(int index) {
|
public boolean canSelect(int index) {
|
||||||
if (isInputBlocked())
|
if (isInputBlocked())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -386,7 +373,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
sortMenu.setBackgroundColor(Colors.BLACK_BG_HOVER);
|
sortMenu.setBackgroundColor(Colors.BLACK_BG_HOVER);
|
||||||
sortMenu.setBorderColor(Colors.BLUE_DIVIDER);
|
sortMenu.setBorderColor(Colors.BLUE_DIVIDER);
|
||||||
sortMenu.setChevronRightColor(Color.white);
|
sortMenu.setChevronRightColor(Color.white);
|
||||||
*/
|
components.add(sortMenu);
|
||||||
|
|
||||||
// initialize group tabs
|
// initialize group tabs
|
||||||
for (BeatmapGroup group : BeatmapGroup.values())
|
for (BeatmapGroup group : BeatmapGroup.values())
|
||||||
|
@ -406,20 +393,20 @@ public class SongMenu extends BaseOpsuState {
|
||||||
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
||||||
|
|
||||||
// search
|
// search
|
||||||
// TODO d reenable search box
|
|
||||||
/*
|
|
||||||
int textFieldX = (int) (displayContainer.width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
int textFieldX = (int) (displayContainer.width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
||||||
int textFieldY = (int) (headerY + Fonts.BOLD.getLineHeight() / 2);
|
int textFieldY = (int) (headerY + Fonts.BOLD.getLineHeight() / 2);
|
||||||
search = new TextField(
|
searchTextField = new TextField(displayContainer, Fonts.BOLD, textFieldX, textFieldY, (int) (displayContainer.width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()) {
|
||||||
container, Fonts.BOLD, textFieldX, textFieldY,
|
@Override
|
||||||
(int) (displayContainer.width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()
|
public boolean isFocusable() {
|
||||||
);
|
return false;
|
||||||
search.setBackgroundColor(Color.transparent);
|
}
|
||||||
search.setBorderColor(Color.transparent);
|
};
|
||||||
search.setTextColor(Color.white);
|
searchTextField.setBackgroundColor(Color.transparent);
|
||||||
search.setConsumeEvents(false);
|
searchTextField.setBorderColor(Color.transparent);
|
||||||
search.setMaxLength(60);
|
searchTextField.setTextColor(Color.white);
|
||||||
*/
|
searchTextField.setMaxLength(60);
|
||||||
|
searchTextField.setFocused(true);
|
||||||
|
components.add(searchTextField);
|
||||||
|
|
||||||
// selection buttons
|
// selection buttons
|
||||||
Image selectionMods = GameImage.SELECTION_MODS.getImage();
|
Image selectionMods = GameImage.SELECTION_MODS.getImage();
|
||||||
|
@ -482,9 +469,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
int mouseX = displayContainer.mouseX;
|
int mouseX = displayContainer.mouseX;
|
||||||
int mouseY = displayContainer.mouseY;
|
int mouseY = displayContainer.mouseY;
|
||||||
|
|
||||||
// TODO d
|
|
||||||
//boolean inDropdownMenu = sortMenu.contains(mouseX, mouseY);
|
|
||||||
|
|
||||||
// background
|
// background
|
||||||
if (focusNode != null) {
|
if (focusNode != null) {
|
||||||
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
|
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
|
||||||
|
@ -555,11 +539,9 @@ public class SongMenu extends BaseOpsuState {
|
||||||
g.clearClip();
|
g.clearClip();
|
||||||
|
|
||||||
// scroll bar
|
// scroll bar
|
||||||
// TODO d
|
if (focusScores.length > MAX_SCORE_BUTTONS && ScoreData.areaContains(mouseX, mouseY) && !isAnyComponentFocused()) {
|
||||||
/*
|
|
||||||
if (focusScores.length > MAX_SCORE_BUTTONS && ScoreData.areaContains(mouseX, mouseY) && !inDropdownMenu)
|
|
||||||
ScoreData.drawScrollbar(g, startScorePos.getPosition(), focusScores.length * ScoreData.getButtonOffset());
|
ScoreData.drawScrollbar(g, startScorePos.getPosition(), focusScores.length * ScoreData.getButtonOffset());
|
||||||
*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// top/bottom bars
|
// top/bottom bars
|
||||||
|
@ -576,9 +558,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
Float position = MusicController.getBeatProgress();
|
Float position = MusicController.getBeatProgress();
|
||||||
if (position == null) // default to 60bpm
|
if (position == null) // default to 60bpm
|
||||||
position = System.currentTimeMillis() % 1000 / 1000f;
|
position = System.currentTimeMillis() % 1000 / 1000f;
|
||||||
// TODO d
|
if (footerLogoButton.contains(mouseX, mouseY, 0.25f)) {
|
||||||
/*
|
|
||||||
if (footerLogoButton.contains(mouseX, mouseY, 0.25f) && !inDropdownMenu) {
|
|
||||||
// hovering over logo: stop pulsing
|
// hovering over logo: stop pulsing
|
||||||
footerLogoButton.draw();
|
footerLogoButton.draw();
|
||||||
} else {
|
} else {
|
||||||
|
@ -591,7 +571,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
ghostLogo.drawCentered(footerLogoButton.getX(), footerLogoButton.getY(), Colors.GHOST_LOGO);
|
ghostLogo.drawCentered(footerLogoButton.getX(), footerLogoButton.getY(), Colors.GHOST_LOGO);
|
||||||
Colors.GHOST_LOGO.a = oldGhostAlpha;
|
Colors.GHOST_LOGO.a = oldGhostAlpha;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// header
|
// header
|
||||||
if (focusNode != null) {
|
if (focusNode != null) {
|
||||||
|
@ -672,9 +651,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
// group tabs
|
// group tabs
|
||||||
BeatmapGroup currentGroup = BeatmapGroup.current();
|
BeatmapGroup currentGroup = BeatmapGroup.current();
|
||||||
BeatmapGroup hoverGroup = null;
|
BeatmapGroup hoverGroup = null;
|
||||||
// TODO d
|
if (!isAnyComponentFocused()) {
|
||||||
/*
|
|
||||||
if (!inDropdownMenu) {
|
|
||||||
for (BeatmapGroup group : BeatmapGroup.values()) {
|
for (BeatmapGroup group : BeatmapGroup.values()) {
|
||||||
if (group.contains(mouseX, mouseY)) {
|
if (group.contains(mouseX, mouseY)) {
|
||||||
hoverGroup = group;
|
hoverGroup = group;
|
||||||
|
@ -682,7 +659,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
for (BeatmapGroup group : BeatmapGroup.VALUES_REVERSED) {
|
for (BeatmapGroup group : BeatmapGroup.VALUES_REVERSED) {
|
||||||
if (group != currentGroup)
|
if (group != currentGroup)
|
||||||
group.draw(false, group == hoverGroup);
|
group.draw(false, group == hoverGroup);
|
||||||
|
@ -690,10 +666,9 @@ public class SongMenu extends BaseOpsuState {
|
||||||
currentGroup.draw(true, false);
|
currentGroup.draw(true, false);
|
||||||
|
|
||||||
// search
|
// search
|
||||||
// TODO d
|
boolean searchEmpty = searchTextField.getText().isEmpty();
|
||||||
/*
|
int searchX = searchTextField.x;
|
||||||
boolean searchEmpty = search.getText().isEmpty();
|
int searchY = searchTextField.y;
|
||||||
int searchX = search.getX(), searchY = search.getY();
|
|
||||||
float searchBaseX = width * 0.7f;
|
float searchBaseX = width * 0.7f;
|
||||||
float searchTextX = width * 0.7125f;
|
float searchTextX = width * 0.7125f;
|
||||||
float searchRectHeight = Fonts.BOLD.getLineHeight() * 2;
|
float searchRectHeight = Fonts.BOLD.getLineHeight() * 2;
|
||||||
|
@ -712,21 +687,15 @@ public class SongMenu extends BaseOpsuState {
|
||||||
g.fillRect(searchBaseX, headerY + DIVIDER_LINE_WIDTH / 2, width - searchBaseX, searchRectHeight);
|
g.fillRect(searchBaseX, headerY + DIVIDER_LINE_WIDTH / 2, width - searchBaseX, searchRectHeight);
|
||||||
Colors.BLACK_ALPHA.a = oldAlpha;
|
Colors.BLACK_ALPHA.a = oldAlpha;
|
||||||
Fonts.BOLD.drawString(searchTextX, searchY, "Search:", Colors.GREEN_SEARCH);
|
Fonts.BOLD.drawString(searchTextX, searchY, "Search:", Colors.GREEN_SEARCH);
|
||||||
if (searchEmpty)
|
if (searchEmpty) {
|
||||||
Fonts.BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
Fonts.BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
||||||
else {
|
} else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
// TODO: why is this needed to correctly position the TextField?
|
searchTextField.render(g);
|
||||||
search.setLocation(searchX - 3, searchY - 1);
|
Fonts.DEFAULT.drawString(searchTextX, searchY + Fonts.BOLD.getLineHeight(), (searchResultString == null) ? "Searching..." : searchResultString, Color.white);
|
||||||
search.render(container, g);
|
|
||||||
search.setLocation(searchX, searchY);
|
|
||||||
Fonts.DEFAULT.drawString(searchTextX, searchY + Fonts.BOLD.getLineHeight(),
|
|
||||||
(searchResultString == null) ? "Searching..." : searchResultString, Color.white);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sorting options
|
sortMenu.render(g);
|
||||||
sortMenu.render(container, g);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// reloading beatmaps
|
// reloading beatmaps
|
||||||
if (reloadThread != null) {
|
if (reloadThread != null) {
|
||||||
|
@ -766,7 +735,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
int mouseX = displayContainer.mouseX;
|
int mouseX = displayContainer.mouseX;
|
||||||
int mouseY = displayContainer.mouseY;
|
int mouseY = displayContainer.mouseY;
|
||||||
boolean inDropdownMenu = false; // TODO d sortMenu.contains(mouseX, mouseY);
|
|
||||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||||
selectModsButton.hoverUpdate(delta, mouseX, mouseY);
|
selectModsButton.hoverUpdate(delta, mouseX, mouseY);
|
||||||
selectRandomButton.hoverUpdate(delta, mouseX, mouseY);
|
selectRandomButton.hoverUpdate(delta, mouseX, mouseY);
|
||||||
|
@ -805,9 +773,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
starStream.update(delta);
|
starStream.update(delta);
|
||||||
|
|
||||||
// search
|
// search
|
||||||
// TODO d
|
|
||||||
/*
|
|
||||||
search.setFocus(true);
|
|
||||||
searchTimer += delta;
|
searchTimer += delta;
|
||||||
if (searchTimer >= SEARCH_DELAY && reloadThread == null && beatmapMenuTimer == -1) {
|
if (searchTimer >= SEARCH_DELAY && reloadThread == null && beatmapMenuTimer == -1) {
|
||||||
searchTimer = 0;
|
searchTimer = 0;
|
||||||
|
@ -816,12 +781,12 @@ public class SongMenu extends BaseOpsuState {
|
||||||
if (focusNode != null)
|
if (focusNode != null)
|
||||||
oldFocusNode = new SongNode(BeatmapSetList.get().getBaseNode(focusNode.index), focusNode.beatmapIndex);
|
oldFocusNode = new SongNode(BeatmapSetList.get().getBaseNode(focusNode.index), focusNode.beatmapIndex);
|
||||||
|
|
||||||
if (BeatmapSetList.get().search(search.getText())) {
|
if (BeatmapSetList.get().search(searchTextField.getText())) {
|
||||||
// reset song stack
|
// reset song stack
|
||||||
randomStack = new Stack<SongNode>();
|
randomStack = new Stack<>();
|
||||||
|
|
||||||
// empty search
|
// empty search
|
||||||
if (search.getText().isEmpty())
|
if (searchTextField.getText().isEmpty())
|
||||||
searchResultString = null;
|
searchResultString = null;
|
||||||
|
|
||||||
// search produced new list: re-initialize it
|
// search produced new list: re-initialize it
|
||||||
|
@ -830,7 +795,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
focusScores = null;
|
focusScores = null;
|
||||||
if (BeatmapSetList.get().size() > 0) {
|
if (BeatmapSetList.get().size() > 0) {
|
||||||
BeatmapSetList.get().init();
|
BeatmapSetList.get().init();
|
||||||
if (search.getText().isEmpty()) { // cleared search
|
if (searchTextField.getText().isEmpty()) { // cleared search
|
||||||
// use previous start/focus if possible
|
// use previous start/focus if possible
|
||||||
if (oldFocusNode != null)
|
if (oldFocusNode != null)
|
||||||
setFocus(oldFocusNode.getNode(), oldFocusNode.getIndex(), true, true);
|
setFocus(oldFocusNode.getNode(), oldFocusNode.getIndex(), true, true);
|
||||||
|
@ -843,7 +808,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||||
}
|
}
|
||||||
oldFocusNode = null;
|
oldFocusNode = null;
|
||||||
} else if (!search.getText().isEmpty())
|
} else if (!searchTextField.getText().isEmpty())
|
||||||
searchResultString = "No matches found. Hit ESC to reset.";
|
searchResultString = "No matches found. Hit ESC to reset.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,7 +817,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
if (searchTransitionTimer > SEARCH_TRANSITION_TIME)
|
if (searchTransitionTimer > SEARCH_TRANSITION_TIME)
|
||||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// scores
|
// scores
|
||||||
if (focusScores != null) {
|
if (focusScores != null) {
|
||||||
|
@ -874,7 +838,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
|
|
||||||
// mouse hover
|
// mouse hover
|
||||||
BeatmapSetNode node = getNodeAtPosition(mouseX, mouseY);
|
BeatmapSetNode node = getNodeAtPosition(mouseX, mouseY);
|
||||||
if (node != null && !inDropdownMenu) {
|
if (node != null && !isAnyComponentFocused()) {
|
||||||
if (node == hoverIndex)
|
if (node == hoverIndex)
|
||||||
hoverOffset.update(delta);
|
hoverOffset.update(delta);
|
||||||
else {
|
else {
|
||||||
|
@ -888,11 +852,9 @@ public class SongMenu extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// tooltips
|
// tooltips
|
||||||
// TODO d
|
|
||||||
/*
|
|
||||||
if (sortMenu.baseContains(mouseX, mouseY))
|
if (sortMenu.baseContains(mouseX, mouseY))
|
||||||
UI.updateTooltip(delta, "Sort by...", false);
|
UI.updateTooltip(delta, "Sort by...", false);
|
||||||
else */if (focusScores != null && ScoreData.areaContains(mouseX, mouseY)) {
|
else if (focusScores != null && ScoreData.areaContains(mouseX, mouseY)) {
|
||||||
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
||||||
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
||||||
int scoreButtons = Math.min(focusScores.length - startScore, MAX_SCORE_BUTTONS);
|
int scoreButtons = Math.min(focusScores.length - startScore, MAX_SCORE_BUTTONS);
|
||||||
|
@ -909,6 +871,10 @@ public class SongMenu extends BaseOpsuState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mousePressed(int button, int x, int y) {
|
public boolean mousePressed(int button, int x, int y) {
|
||||||
|
if (super.mousePressed(button, x, y)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (button == Input.MOUSE_MIDDLE_BUTTON) {
|
if (button == Input.MOUSE_MIDDLE_BUTTON) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -924,6 +890,10 @@ public class SongMenu extends BaseOpsuState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(int button, int x, int y) {
|
public boolean mouseReleased(int button, int x, int y) {
|
||||||
|
if (super.mouseReleased(button, x, y)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (button == Input.MOUSE_MIDDLE_BUTTON) {
|
if (button == Input.MOUSE_MIDDLE_BUTTON) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -973,7 +943,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
songInfo = null;
|
songInfo = null;
|
||||||
scoreMap = null;
|
scoreMap = null;
|
||||||
focusScores = null;
|
focusScores = null;
|
||||||
// TODO d search.setText("");
|
searchTextField.setText("");
|
||||||
searchTimer = SEARCH_DELAY;
|
searchTimer = SEARCH_DELAY;
|
||||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||||
searchResultString = null;
|
searchResultString = null;
|
||||||
|
@ -1076,18 +1046,16 @@ public class SongMenu extends BaseOpsuState {
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case Input.KEY_ESCAPE:
|
case Input.KEY_ESCAPE:
|
||||||
// TODO d
|
|
||||||
/*
|
|
||||||
if (reloadThread != null) {
|
if (reloadThread != null) {
|
||||||
// beatmap reloading: stop parsing beatmaps by sending interrupt to BeatmapParser
|
// beatmap reloading: stop parsing beatmaps by sending interrupt to BeatmapParser
|
||||||
reloadThread.interrupt();
|
reloadThread.interrupt();
|
||||||
} else if (!search.getText().isEmpty()) {
|
} else if (!searchTextField.getText().isEmpty()) {
|
||||||
// clear search text
|
// clear search text
|
||||||
search.setText("");
|
searchTextField.setText("");
|
||||||
searchTimer = SEARCH_DELAY;
|
searchTimer = SEARCH_DELAY;
|
||||||
searchTransitionTimer = 0;
|
searchTransitionTimer = 0;
|
||||||
searchResultString = null;
|
searchResultString = null;
|
||||||
} else*/ {
|
} else {
|
||||||
// return to main menu
|
// return to main menu
|
||||||
SoundController.playSound(SoundEffect.MENUBACK);
|
SoundController.playSound(SoundEffect.MENUBACK);
|
||||||
displayContainer.switchState(MainMenu.class);
|
displayContainer.switchState(MainMenu.class);
|
||||||
|
@ -1206,9 +1174,8 @@ public class SongMenu extends BaseOpsuState {
|
||||||
// TODO: accept all characters (current conditions are from TextField class)
|
// TODO: accept all characters (current conditions are from TextField class)
|
||||||
if ((c > 31 && c < 127) || key == Input.KEY_BACK) {
|
if ((c > 31 && c < 127) || key == Input.KEY_BACK) {
|
||||||
searchTimer = 0;
|
searchTimer = 0;
|
||||||
// TODO d
|
searchTextField.keyPressed(key, c);
|
||||||
//int textLength = search.getText().length();
|
int textLength = searchTextField.getText().length();
|
||||||
int textLength = 0;
|
|
||||||
if (lastSearchTextLength != textLength) {
|
if (lastSearchTextLength != textLength) {
|
||||||
if (key == Input.KEY_BACK) {
|
if (key == Input.KEY_BACK) {
|
||||||
if (textLength == 0)
|
if (textLength == 0)
|
||||||
|
@ -1223,36 +1190,38 @@ public class SongMenu extends BaseOpsuState {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO d
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
public boolean mouseDragged(int oldx, int oldy, int newx, int newy) {
|
||||||
// block input
|
if (super.mouseDragged(oldx, oldy, newx, newy)) {
|
||||||
if (isInputBlocked())
|
return true;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if (isInputBlocked()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int diff = newy - oldy;
|
int diff = newy - oldy;
|
||||||
if (diff == 0)
|
if (diff == 0) {
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check mouse button (right click scrolls faster on songs)
|
// check mouse button (right click scrolls faster on songs)
|
||||||
int multiplier;
|
int multiplier;
|
||||||
if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON))
|
if (displayContainer.input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
|
||||||
multiplier = 10;
|
multiplier = 10;
|
||||||
else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
|
} else if (displayContainer.input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
|
||||||
multiplier = 1;
|
multiplier = 1;
|
||||||
else
|
} else {
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// score buttons
|
if (focusScores != null && focusScores.length >= MAX_SCORE_BUTTONS && ScoreData.areaContains(oldx, oldy)) {
|
||||||
if (focusScores != null && focusScores.length >= MAX_SCORE_BUTTONS && ScoreData.areaContains(oldx, oldy))
|
|
||||||
startScorePos.dragged(-diff * multiplier);
|
startScorePos.dragged(-diff * multiplier);
|
||||||
|
} else {
|
||||||
// song buttons
|
|
||||||
else
|
|
||||||
songScrolling.dragged(-diff * multiplier);
|
songScrolling.dragged(-diff * multiplier);
|
||||||
}
|
}
|
||||||
*/
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseWheelMoved(int newValue) {
|
public boolean mouseWheelMoved(int newValue) {
|
||||||
|
@ -1302,12 +1271,10 @@ public class SongMenu extends BaseOpsuState {
|
||||||
songChangeTimer.setTime(songChangeTimer.getDuration());
|
songChangeTimer.setTime(songChangeTimer.getDuration());
|
||||||
musicIconBounceTimer.setTime(musicIconBounceTimer.getDuration());
|
musicIconBounceTimer.setTime(musicIconBounceTimer.getDuration());
|
||||||
starStream.clear();
|
starStream.clear();
|
||||||
// TODO d
|
sortMenu.reset();
|
||||||
//sortMenu.activate();
|
|
||||||
//sortMenu.reset();
|
|
||||||
|
|
||||||
// reset song stack
|
// reset song stack
|
||||||
randomStack = new Stack<SongNode>();
|
randomStack = new Stack<>();
|
||||||
|
|
||||||
// reload beatmaps if song folder changed
|
// reload beatmaps if song folder changed
|
||||||
if (songFolderChanged && stateAction != MenuState.RELOAD)
|
if (songFolderChanged && stateAction != MenuState.RELOAD)
|
||||||
|
@ -1467,16 +1434,6 @@ public class SongMenu extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void leave() {
|
|
||||||
super.leave();
|
|
||||||
// TODO d
|
|
||||||
/*
|
|
||||||
search.setFocus(false);
|
|
||||||
sortMenu.deactivate();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shifts the startNode forward (+) or backwards (-) by a given number of nodes.
|
* Shifts the startNode forward (+) or backwards (-) by a given number of nodes.
|
||||||
* Initiates sliding "animation" by shifting the button Y position.
|
* Initiates sliding "animation" by shifting the button Y position.
|
||||||
|
@ -1734,8 +1691,7 @@ public class SongMenu extends BaseOpsuState {
|
||||||
songInfo = null;
|
songInfo = null;
|
||||||
hoverOffset.setTime(0);
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = null;
|
hoverIndex = null;
|
||||||
// TODO d
|
searchTextField.setText("");
|
||||||
//search.setText("");
|
|
||||||
searchTimer = SEARCH_DELAY;
|
searchTimer = SEARCH_DELAY;
|
||||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||||
searchResultString = null;
|
searchResultString = null;
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class ComplexOpsuState extends BaseOpsuState {
|
||||||
}
|
}
|
||||||
focusedComponent.setFocused(false);
|
focusedComponent.setFocused(false);
|
||||||
focusedComponent = null;
|
focusedComponent = null;
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user