Merge remote-tracking branch 'org/master' into KinecticScrolling
Conflicts: src/itdelatrisu/opsu/ScoreData.java src/itdelatrisu/opsu/downloads/DownloadNode.java src/itdelatrisu/opsu/states/DownloadsMenu.java src/itdelatrisu/opsu/states/SongMenu.java
This commit is contained in:
@@ -29,8 +29,11 @@ import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -187,15 +190,15 @@ public class ButtonMenu extends BasicGameState {
|
||||
float mult = GameMod.getScoreMultiplier();
|
||||
String multString = String.format("Score Multiplier: %.2fx", mult);
|
||||
Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red;
|
||||
float multY = Utils.FONT_LARGE.getLineHeight() * 2 + height * 0.06f;
|
||||
Utils.FONT_LARGE.drawString(
|
||||
(width - Utils.FONT_LARGE.getWidth(multString)) / 2f,
|
||||
float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f;
|
||||
Fonts.LARGE.drawString(
|
||||
(width - Fonts.LARGE.getWidth(multString)) / 2f,
|
||||
multY, multString, multColor);
|
||||
|
||||
// category text
|
||||
for (GameMod.Category category : GameMod.Category.values()) {
|
||||
Utils.FONT_LARGE.drawString(category.getX(),
|
||||
category.getY() - Utils.FONT_LARGE.getLineHeight() / 2f,
|
||||
Fonts.LARGE.drawString(category.getX(),
|
||||
category.getY() - Fonts.LARGE.getLineHeight() / 2f,
|
||||
category.getName(), category.getColor());
|
||||
}
|
||||
|
||||
@@ -217,7 +220,7 @@ public class ButtonMenu extends BasicGameState {
|
||||
}
|
||||
|
||||
// tooltips
|
||||
if (hoverMod != null && hoverMod.isImplemented())
|
||||
if (hoverMod != null)
|
||||
UI.updateTooltip(delta, hoverMod.getDescription(), true);
|
||||
}
|
||||
|
||||
@@ -253,7 +256,7 @@ public class ButtonMenu extends BasicGameState {
|
||||
};
|
||||
|
||||
/** The buttons in the state. */
|
||||
private Button[] buttons;
|
||||
private final Button[] buttons;
|
||||
|
||||
/** The associated MenuButton objects. */
|
||||
private MenuButton[] menuButtons;
|
||||
@@ -261,8 +264,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
/** The actual title string list, generated upon entering the state. */
|
||||
private List<String> actualTitle;
|
||||
|
||||
/** The horizontal center offset, used for the initial button animation. */
|
||||
private AnimatedValue centerOffset;
|
||||
|
||||
/** Initial x coordinate offsets left/right of center (for shifting animation), times width. (TODO) */
|
||||
private static final float OFFSET_WIDTH_RATIO = 1 / 18f;
|
||||
private static final float OFFSET_WIDTH_RATIO = 1 / 25f;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -288,7 +294,7 @@ public class ButtonMenu extends BasicGameState {
|
||||
menuButtons = new MenuButton[buttons.length];
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
MenuButton b = new MenuButton(button, buttonL, buttonR, center, baseY + (i * offsetY));
|
||||
b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Utils.FONT_XLARGE, Color.white);
|
||||
b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Fonts.XLARGE, Color.white);
|
||||
b.setHoverFade();
|
||||
menuButtons[i] = b;
|
||||
}
|
||||
@@ -301,7 +307,7 @@ public class ButtonMenu extends BasicGameState {
|
||||
*/
|
||||
protected float getBaseY(GameContainer container, StateBasedGame game) {
|
||||
float baseY = container.getHeight() * 0.2f;
|
||||
baseY += ((getTitle(container, game).length - 1) * Utils.FONT_LARGE.getLineHeight());
|
||||
baseY += ((getTitle(container, game).length - 1) * Fonts.LARGE.getLineHeight());
|
||||
return baseY;
|
||||
}
|
||||
|
||||
@@ -315,9 +321,9 @@ public class ButtonMenu extends BasicGameState {
|
||||
// draw title
|
||||
if (actualTitle != null) {
|
||||
float marginX = container.getWidth() * 0.015f, marginY = container.getHeight() * 0.01f;
|
||||
int lineHeight = Utils.FONT_LARGE.getLineHeight();
|
||||
int lineHeight = Fonts.LARGE.getLineHeight();
|
||||
for (int i = 0, size = actualTitle.size(); i < size; i++)
|
||||
Utils.FONT_LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
|
||||
Fonts.LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
|
||||
}
|
||||
|
||||
// draw buttons
|
||||
@@ -336,18 +342,14 @@ public class ButtonMenu extends BasicGameState {
|
||||
*/
|
||||
public void update(GameContainer container, int delta, int mouseX, int mouseY) {
|
||||
float center = container.getWidth() / 2f;
|
||||
boolean centerOffsetUpdated = centerOffset.update(delta);
|
||||
float centerOffsetX = centerOffset.getValue();
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
menuButtons[i].hoverUpdate(delta, mouseX, mouseY);
|
||||
|
||||
// move button to center
|
||||
float x = menuButtons[i].getX();
|
||||
if (i % 2 == 0) {
|
||||
if (x < center)
|
||||
menuButtons[i].setX(Math.min(x + (delta / 5f), center));
|
||||
} else {
|
||||
if (x > center)
|
||||
menuButtons[i].setX(Math.max(x - (delta / 5f), center));
|
||||
}
|
||||
if (centerOffsetUpdated)
|
||||
menuButtons[i].setX((i % 2 == 0) ? center + centerOffsetX : center - centerOffsetX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,9 +406,10 @@ public class ButtonMenu extends BasicGameState {
|
||||
*/
|
||||
public void enter(GameContainer container, StateBasedGame game) {
|
||||
float center = container.getWidth() / 2f;
|
||||
float centerOffset = container.getWidth() * OFFSET_WIDTH_RATIO;
|
||||
float centerOffsetX = container.getWidth() * OFFSET_WIDTH_RATIO;
|
||||
centerOffset = new AnimatedValue(700, centerOffsetX, 0, AnimationEquation.OUT_BOUNCE);
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
menuButtons[i].setX(center + ((i % 2 == 0) ? centerOffset * -1 : centerOffset));
|
||||
menuButtons[i].setX(center + ((i % 2 == 0) ? centerOffsetX : centerOffsetX * -1));
|
||||
menuButtons[i].resetHover();
|
||||
}
|
||||
|
||||
@@ -416,8 +419,8 @@ public class ButtonMenu extends BasicGameState {
|
||||
int maxLineWidth = (int) (container.getWidth() * 0.96f);
|
||||
for (int i = 0; i < title.length; i++) {
|
||||
// wrap text if too long
|
||||
if (Utils.FONT_LARGE.getWidth(title[i]) > maxLineWidth) {
|
||||
List<String> list = Utils.wrap(title[i], Utils.FONT_LARGE, maxLineWidth);
|
||||
if (Fonts.LARGE.getWidth(title[i]) > maxLineWidth) {
|
||||
List<String> list = Fonts.wrap(Fonts.LARGE, title[i], maxLineWidth);
|
||||
actualTitle.addAll(list);
|
||||
} else
|
||||
actualTitle.add(title[i]);
|
||||
@@ -545,10 +548,10 @@ public class ButtonMenu extends BasicGameState {
|
||||
};
|
||||
|
||||
/** The text to show on the button. */
|
||||
private String text;
|
||||
private final String text;
|
||||
|
||||
/** The button color. */
|
||||
private Color color;
|
||||
private final Color color;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -591,7 +594,7 @@ public class ButtonMenu extends BasicGameState {
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public ButtonMenu(int state) {
|
||||
this.state = state;
|
||||
|
||||
@@ -21,7 +21,6 @@ package itdelatrisu.opsu.states;
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.OszUnpacker;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
@@ -29,13 +28,19 @@ import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
||||
import itdelatrisu.opsu.beatmap.OszUnpacker;
|
||||
import itdelatrisu.opsu.downloads.Download;
|
||||
import itdelatrisu.opsu.downloads.DownloadList;
|
||||
import itdelatrisu.opsu.downloads.DownloadNode;
|
||||
import itdelatrisu.opsu.downloads.servers.BloodcatServer;
|
||||
import itdelatrisu.opsu.downloads.servers.DownloadServer;
|
||||
import itdelatrisu.opsu.downloads.servers.HexideServer;
|
||||
import itdelatrisu.opsu.downloads.servers.OsuMirrorServer;
|
||||
import itdelatrisu.opsu.downloads.servers.MengSkyServer;
|
||||
import itdelatrisu.opsu.downloads.servers.MnetworkServer;
|
||||
import itdelatrisu.opsu.downloads.servers.YaSOnlineServer;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.DropdownMenu;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.KinecticScrolling;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
@@ -75,10 +80,10 @@ public class DownloadsMenu extends BasicGameState {
|
||||
private static final int MIN_REQUEST_INTERVAL = 300;
|
||||
|
||||
/** Available beatmap download servers. */
|
||||
private static final DownloadServer[] SERVERS = { new BloodcatServer(), new OsuMirrorServer(), new HexideServer() };
|
||||
|
||||
/** The beatmap download server index. */
|
||||
private int serverIndex = 0;
|
||||
private static final DownloadServer[] SERVERS = {
|
||||
new BloodcatServer(), new HexideServer(), new YaSOnlineServer(),
|
||||
new MnetworkServer(), new MengSkyServer()
|
||||
};
|
||||
|
||||
/** The current list of search results. */
|
||||
private DownloadNode[] resultList;
|
||||
@@ -137,14 +142,14 @@ public class DownloadsMenu extends BasicGameState {
|
||||
/** Page direction for last query. */
|
||||
private Page lastQueryDir = Page.RESET;
|
||||
|
||||
/** Number of active requests. */
|
||||
private int activeRequests = 0;
|
||||
|
||||
/** Previous and next page buttons. */
|
||||
private MenuButton prevPage, nextPage;
|
||||
|
||||
/** Buttons. */
|
||||
private MenuButton clearButton, importButton, resetButton, rankedButton, serverButton;
|
||||
private MenuButton clearButton, importButton, resetButton, rankedButton;
|
||||
|
||||
/** Dropdown menu. */
|
||||
private DropdownMenu<DownloadServer> serverMenu;
|
||||
|
||||
/** Beatmap importing thread. */
|
||||
private Thread importThread;
|
||||
@@ -155,11 +160,97 @@ public class DownloadsMenu extends BasicGameState {
|
||||
/** The bar notification to send upon entering the state. */
|
||||
private String barNotificationOnLoad;
|
||||
|
||||
/** Search query, executed in {@code queryThread}. */
|
||||
private SearchQuery searchQuery;
|
||||
|
||||
/** Search query helper class. */
|
||||
private class SearchQuery implements Runnable {
|
||||
/** The search query. */
|
||||
private final String query;
|
||||
|
||||
/** The download server. */
|
||||
private final DownloadServer server;
|
||||
|
||||
/** Whether the query was interrupted. */
|
||||
private boolean interrupted = false;
|
||||
|
||||
/** Whether the query has completed execution. */
|
||||
private boolean complete = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param query the search query
|
||||
* @param server the download server
|
||||
*/
|
||||
public SearchQuery(String query, DownloadServer server) {
|
||||
this.query = query;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/** Interrupt the query and prevent the results from being processed, if not already complete. */
|
||||
public void interrupt() { interrupted = true; }
|
||||
|
||||
/** Returns whether the query has completed execution. */
|
||||
public boolean isComplete() { return complete; }
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// check page direction
|
||||
Page lastPageDir = pageDir;
|
||||
pageDir = Page.RESET;
|
||||
int lastPageSize = (resultList != null) ? resultList.length : 0;
|
||||
int newPage = page;
|
||||
if (lastPageDir == Page.RESET)
|
||||
newPage = 1;
|
||||
else if (lastPageDir == Page.NEXT)
|
||||
newPage++;
|
||||
else if (lastPageDir == Page.PREVIOUS)
|
||||
newPage--;
|
||||
try {
|
||||
DownloadNode[] nodes = server.resultList(query, newPage, rankedOnly);
|
||||
if (!interrupted) {
|
||||
// update page total
|
||||
page = newPage;
|
||||
if (nodes != null) {
|
||||
if (lastPageDir == Page.NEXT)
|
||||
pageResultTotal += nodes.length;
|
||||
else if (lastPageDir == Page.PREVIOUS)
|
||||
pageResultTotal -= lastPageSize;
|
||||
else if (lastPageDir == Page.RESET)
|
||||
pageResultTotal = nodes.length;
|
||||
} else
|
||||
pageResultTotal = 0;
|
||||
|
||||
resultList = nodes;
|
||||
totalResults = server.totalResults();
|
||||
focusResult = -1;
|
||||
startResultPos.setPosition(0);
|
||||
if (nodes == null)
|
||||
searchResultString = "An error has occurred.";
|
||||
else {
|
||||
if (query.isEmpty())
|
||||
searchResultString = "Type to search!";
|
||||
else if (totalResults == 0 || resultList.length == 0)
|
||||
searchResultString = "No results found.";
|
||||
else
|
||||
searchResultString = String.format("%d result%s found!",
|
||||
totalResults, (totalResults == 1) ? "" : "s");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (!interrupted)
|
||||
searchResultString = "Could not establish connection to server.";
|
||||
} finally {
|
||||
complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public DownloadsMenu(int state) {
|
||||
this.state = state;
|
||||
@@ -175,17 +266,17 @@ public class DownloadsMenu extends BasicGameState {
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
float baseX = width * 0.024f;
|
||||
float searchY = (height * 0.04f) + Utils.FONT_LARGE.getLineHeight();
|
||||
float searchY = (height * 0.04f) + Fonts.LARGE.getLineHeight();
|
||||
float searchWidth = width * 0.3f;
|
||||
|
||||
// search
|
||||
searchTimer = SEARCH_DELAY;
|
||||
searchResultString = "Loading data from server...";
|
||||
search = new TextField(
|
||||
container, Utils.FONT_DEFAULT, (int) baseX, (int) searchY,
|
||||
(int) searchWidth, Utils.FONT_MEDIUM.getLineHeight()
|
||||
container, Fonts.DEFAULT, (int) baseX, (int) searchY,
|
||||
(int) searchWidth, Fonts.MEDIUM.getLineHeight()
|
||||
);
|
||||
search.setBackgroundColor(DownloadNode.BG_NORMAL);
|
||||
search.setBackgroundColor(Colors.BLACK_BG_NORMAL);
|
||||
search.setBorderColor(Color.white);
|
||||
search.setTextColor(Color.white);
|
||||
search.setConsumeEvents(false);
|
||||
@@ -208,9 +299,8 @@ public class DownloadsMenu extends BasicGameState {
|
||||
float buttonHeight = height * 0.038f;
|
||||
float resetWidth = width * 0.085f;
|
||||
float rankedWidth = width * 0.15f;
|
||||
float serverWidth = width * 0.12f;
|
||||
float lowerWidth = width * 0.12f;
|
||||
float topButtonY = searchY + Utils.FONT_MEDIUM.getLineHeight() / 2f;
|
||||
float topButtonY = searchY + Fonts.MEDIUM.getLineHeight() / 2f;
|
||||
float lowerButtonY = height * 0.995f - searchY - buttonHeight / 2f;
|
||||
Image button = GameImage.MENU_BUTTON_MID.getImage();
|
||||
Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage();
|
||||
@@ -220,11 +310,9 @@ public class DownloadsMenu extends BasicGameState {
|
||||
int lrButtonWidth = buttonL.getWidth() + buttonR.getWidth();
|
||||
Image resetButtonImage = button.getScaledCopy((int) resetWidth - lrButtonWidth, (int) buttonHeight);
|
||||
Image rankedButtonImage = button.getScaledCopy((int) rankedWidth - lrButtonWidth, (int) buttonHeight);
|
||||
Image serverButtonImage = button.getScaledCopy((int) serverWidth - lrButtonWidth, (int) buttonHeight);
|
||||
Image lowerButtonImage = button.getScaledCopy((int) lowerWidth - lrButtonWidth, (int) buttonHeight);
|
||||
float resetButtonWidth = resetButtonImage.getWidth() + lrButtonWidth;
|
||||
float rankedButtonWidth = rankedButtonImage.getWidth() + lrButtonWidth;
|
||||
float serverButtonWidth = serverButtonImage.getWidth() + lrButtonWidth;
|
||||
float lowerButtonWidth = lowerButtonImage.getWidth() + lrButtonWidth;
|
||||
clearButton = new MenuButton(lowerButtonImage, buttonL, buttonR,
|
||||
width * 0.75f + buttonMarginX + lowerButtonWidth / 2f, lowerButtonY);
|
||||
@@ -234,16 +322,48 @@ public class DownloadsMenu extends BasicGameState {
|
||||
baseX + searchWidth + buttonMarginX + resetButtonWidth / 2f, topButtonY);
|
||||
rankedButton = new MenuButton(rankedButtonImage, buttonL, buttonR,
|
||||
baseX + searchWidth + buttonMarginX * 2f + resetButtonWidth + rankedButtonWidth / 2f, topButtonY);
|
||||
serverButton = new MenuButton(serverButtonImage, buttonL, buttonR,
|
||||
baseX + searchWidth + buttonMarginX * 3f + resetButtonWidth + rankedButtonWidth + serverButtonWidth / 2f, topButtonY);
|
||||
clearButton.setText("Clear", Utils.FONT_MEDIUM, Color.white);
|
||||
importButton.setText("Import All", Utils.FONT_MEDIUM, Color.white);
|
||||
resetButton.setText("Reset", Utils.FONT_MEDIUM, Color.white);
|
||||
clearButton.setText("Clear", Fonts.MEDIUM, Color.white);
|
||||
importButton.setText("Import All", Fonts.MEDIUM, Color.white);
|
||||
resetButton.setText("Reset", Fonts.MEDIUM, Color.white);
|
||||
clearButton.setHoverFade();
|
||||
importButton.setHoverFade();
|
||||
resetButton.setHoverFade();
|
||||
rankedButton.setHoverFade();
|
||||
serverButton.setHoverFade();
|
||||
|
||||
// dropdown menu
|
||||
int serverWidth = (int) (width * 0.12f);
|
||||
serverMenu = new DropdownMenu<DownloadServer>(container, SERVERS,
|
||||
baseX + searchWidth + buttonMarginX * 3f + resetButtonWidth + rankedButtonWidth, searchY, serverWidth) {
|
||||
@Override
|
||||
public void itemSelected(int index, DownloadServer item) {
|
||||
resultList = null;
|
||||
startResultPos.setPosition(0);
|
||||
focusResult = -1;
|
||||
totalResults = 0;
|
||||
page = 0;
|
||||
pageResultTotal = 1;
|
||||
pageDir = Page.RESET;
|
||||
searchResultString = "Loading data from server...";
|
||||
lastQuery = null;
|
||||
pageDir = Page.RESET;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean menuClicked(int index) {
|
||||
// block input during beatmap importing
|
||||
if (importThread != null)
|
||||
return false;
|
||||
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
serverMenu.setBackgroundColor(Colors.BLACK_BG_HOVER);
|
||||
serverMenu.setBorderColor(Color.black);
|
||||
serverMenu.setChevronRightColor(Color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,18 +372,19 @@ public class DownloadsMenu extends BasicGameState {
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
boolean inDropdownMenu = serverMenu.contains(mouseX, mouseY);
|
||||
|
||||
// background
|
||||
GameImage.SEARCH_BG.getImage().draw();
|
||||
|
||||
// title
|
||||
Utils.FONT_LARGE.drawString(width * 0.024f, height * 0.03f, "Download Beatmaps!", Color.white);
|
||||
Fonts.LARGE.drawString(width * 0.024f, height * 0.03f, "Download Beatmaps!", Color.white);
|
||||
|
||||
// search
|
||||
g.setColor(Color.white);
|
||||
g.setLineWidth(2f);
|
||||
search.render(container, g);
|
||||
Utils.FONT_BOLD.drawString(
|
||||
Fonts.BOLD.drawString(
|
||||
search.getX() + search.getWidth() * 0.01f, search.getY() + search.getHeight() * 1.3f,
|
||||
searchResultString, Color.white
|
||||
);
|
||||
@@ -283,7 +404,7 @@ public class DownloadsMenu extends BasicGameState {
|
||||
if (index >= nodes.length)
|
||||
break;
|
||||
nodes[index].drawResult(g, offset + i * DownloadNode.getButtonOffset(),
|
||||
DownloadNode.resultContains(mouseX, mouseY - offset, i),
|
||||
DownloadNode.resultContains(mouseX, mouseY - offset, i) && !inDropdownMenu,
|
||||
(index == focusResult), (previewID == nodes[index].getID()));
|
||||
}
|
||||
g.clearClip();
|
||||
@@ -297,9 +418,9 @@ public class DownloadsMenu extends BasicGameState {
|
||||
float baseX = width * 0.024f;
|
||||
float buttonY = height * 0.2f;
|
||||
float buttonWidth = width * 0.7f;
|
||||
Utils.FONT_BOLD.drawString(
|
||||
baseX + (buttonWidth - Utils.FONT_BOLD.getWidth("Page 1")) / 2f,
|
||||
buttonY - Utils.FONT_BOLD.getLineHeight() * 1.3f,
|
||||
Fonts.BOLD.drawString(
|
||||
baseX + (buttonWidth - Fonts.BOLD.getWidth("Page 1")) / 2f,
|
||||
buttonY - Fonts.BOLD.getLineHeight() * 1.3f,
|
||||
String.format("Page %d", page), Color.white
|
||||
);
|
||||
if (page > 1)
|
||||
@@ -311,10 +432,10 @@ public class DownloadsMenu extends BasicGameState {
|
||||
|
||||
// downloads
|
||||
float downloadsX = width * 0.75f, downloadsY = search.getY();
|
||||
g.setColor(DownloadNode.BG_NORMAL);
|
||||
g.setColor(Colors.BLACK_BG_NORMAL);
|
||||
g.fillRect(downloadsX, downloadsY,
|
||||
width * 0.25f, height - downloadsY * 2f);
|
||||
Utils.FONT_LARGE.drawString(downloadsX + width * 0.015f, downloadsY + height * 0.015f, "Downloads", Color.white);
|
||||
Fonts.LARGE.drawString(downloadsX + width * 0.015f, downloadsY + height * 0.015f, "Downloads", Color.white);
|
||||
int downloadsSize = DownloadList.get().size();
|
||||
if (downloadsSize > 0) {
|
||||
int maxDownloadsShown = DownloadNode.maxDownloadsShown();
|
||||
@@ -344,15 +465,16 @@ public class DownloadsMenu extends BasicGameState {
|
||||
clearButton.draw(Color.gray);
|
||||
importButton.draw(Color.orange);
|
||||
resetButton.draw(Color.red);
|
||||
rankedButton.setText((rankedOnly) ? "Show Unranked" : "Hide Unranked", Utils.FONT_MEDIUM, Color.white);
|
||||
rankedButton.setText((rankedOnly) ? "Show Unranked" : "Hide Unranked", Fonts.MEDIUM, Color.white);
|
||||
rankedButton.draw(Color.magenta);
|
||||
serverButton.setText(SERVERS[serverIndex].getName(), Utils.FONT_MEDIUM, Color.white);
|
||||
serverButton.draw(Color.blue);
|
||||
|
||||
// dropdown menu
|
||||
serverMenu.render(container, g);
|
||||
|
||||
// importing beatmaps
|
||||
if (importThread != null) {
|
||||
// darken the screen
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
UI.drawLoadingProgress(g);
|
||||
@@ -379,7 +501,6 @@ public class DownloadsMenu extends BasicGameState {
|
||||
importButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
resetButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
rankedButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
serverButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
|
||||
if (DownloadList.get() != null)
|
||||
startDownloadIndexPos.setMinMax(0, DownloadNode.getInfoHeight() * (DownloadList.get().size() - DownloadNode.maxDownloadsShown()));
|
||||
@@ -399,72 +520,22 @@ public class DownloadsMenu extends BasicGameState {
|
||||
searchTimer = 0;
|
||||
searchTimerReset = false;
|
||||
|
||||
final String query = search.getText().trim().toLowerCase();
|
||||
final DownloadServer server = SERVERS[serverIndex];
|
||||
String query = search.getText().trim().toLowerCase();
|
||||
DownloadServer server = serverMenu.getSelectedItem();
|
||||
if ((lastQuery == null || !query.equals(lastQuery)) &&
|
||||
(query.length() == 0 || query.length() >= server.minQueryLength())) {
|
||||
lastQuery = query;
|
||||
lastQueryDir = pageDir;
|
||||
|
||||
if (queryThread != null && queryThread.isAlive())
|
||||
if (queryThread != null && queryThread.isAlive()) {
|
||||
queryThread.interrupt();
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
}
|
||||
|
||||
// execute query
|
||||
queryThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
activeRequests++;
|
||||
|
||||
// check page direction
|
||||
Page lastPageDir = pageDir;
|
||||
pageDir = Page.RESET;
|
||||
int lastPageSize = (resultList != null) ? resultList.length : 0;
|
||||
int newPage = page;
|
||||
if (lastPageDir == Page.RESET)
|
||||
newPage = 1;
|
||||
else if (lastPageDir == Page.NEXT)
|
||||
newPage++;
|
||||
else if (lastPageDir == Page.PREVIOUS)
|
||||
newPage--;
|
||||
try {
|
||||
DownloadNode[] nodes = server.resultList(query, newPage, rankedOnly);
|
||||
if (activeRequests - 1 == 0) {
|
||||
// update page total
|
||||
page = newPage;
|
||||
if (nodes != null) {
|
||||
if (lastPageDir == Page.NEXT)
|
||||
pageResultTotal += nodes.length;
|
||||
else if (lastPageDir == Page.PREVIOUS)
|
||||
pageResultTotal -= lastPageSize;
|
||||
else if (lastPageDir == Page.RESET)
|
||||
pageResultTotal = nodes.length;
|
||||
} else
|
||||
pageResultTotal = 0;
|
||||
|
||||
resultList = nodes;
|
||||
totalResults = server.totalResults();
|
||||
focusResult = -1;
|
||||
startResultPos.setPosition(0);
|
||||
if (nodes == null)
|
||||
searchResultString = "An error has occurred.";
|
||||
else {
|
||||
if (query.isEmpty())
|
||||
searchResultString = "Type to search!";
|
||||
else if (totalResults == 0 || resultList.length == 0)
|
||||
searchResultString = "No results found.";
|
||||
else
|
||||
searchResultString = String.format("%d result%s found!",
|
||||
totalResults, (totalResults == 1) ? "" : "s");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
searchResultString = "Could not establish connection to server.";
|
||||
} finally {
|
||||
activeRequests--;
|
||||
queryThread = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
searchQuery = new SearchQuery(query, server);
|
||||
queryThread = new Thread(searchQuery);
|
||||
queryThread.start();
|
||||
}
|
||||
}
|
||||
@@ -474,7 +545,7 @@ public class DownloadsMenu extends BasicGameState {
|
||||
UI.updateTooltip(delta, "Reset the current search.", false);
|
||||
else if (rankedButton.contains(mouseX, mouseY))
|
||||
UI.updateTooltip(delta, "Toggle the display of unranked maps.\nSome download servers may not support this option.", true);
|
||||
else if (serverButton.contains(mouseX, mouseY))
|
||||
else if (serverMenu.baseContains(mouseX, mouseY))
|
||||
UI.updateTooltip(delta, "Select a download server.", false);
|
||||
}
|
||||
|
||||
@@ -534,7 +605,7 @@ public class DownloadsMenu extends BasicGameState {
|
||||
} else {
|
||||
// play preview
|
||||
try {
|
||||
final URL url = new URL(SERVERS[serverIndex].getPreviewURL(node.getID()));
|
||||
final URL url = new URL(serverMenu.getSelectedItem().getPreviewURL(node.getID()));
|
||||
MusicController.pause();
|
||||
new Thread() {
|
||||
@Override
|
||||
@@ -578,7 +649,7 @@ public class DownloadsMenu extends BasicGameState {
|
||||
} else {
|
||||
// start download
|
||||
if (!DownloadList.get().contains(node.getID())) {
|
||||
node.createDownload(SERVERS[serverIndex]);
|
||||
node.createDownload(serverMenu.getSelectedItem());
|
||||
if (node.getDownload() == null)
|
||||
UI.sendBarNotification("The download could not be started.");
|
||||
else {
|
||||
@@ -601,23 +672,27 @@ public class DownloadsMenu extends BasicGameState {
|
||||
// pages
|
||||
if (nodes.length > 0) {
|
||||
if (page > 1 && prevPage.contains(x, y)) {
|
||||
if (lastQueryDir == Page.PREVIOUS && queryThread != null && queryThread.isAlive())
|
||||
if (lastQueryDir == Page.PREVIOUS && searchQuery != null && !searchQuery.isComplete())
|
||||
; // don't send consecutive requests
|
||||
else {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
pageDir = Page.PREVIOUS;
|
||||
lastQuery = null;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (pageResultTotal < totalResults && nextPage.contains(x, y)) {
|
||||
if (lastQueryDir == Page.NEXT && queryThread != null && queryThread.isAlive())
|
||||
if (lastQueryDir == Page.NEXT && searchQuery != null && !searchQuery.isComplete())
|
||||
; // don't send consecutive requests
|
||||
else {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
pageDir = Page.NEXT;
|
||||
lastQuery = null;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
return;
|
||||
}
|
||||
@@ -670,6 +745,8 @@ public class DownloadsMenu extends BasicGameState {
|
||||
search.setText("");
|
||||
lastQuery = null;
|
||||
pageDir = Page.RESET;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
return;
|
||||
}
|
||||
@@ -678,22 +755,8 @@ public class DownloadsMenu extends BasicGameState {
|
||||
rankedOnly = !rankedOnly;
|
||||
lastQuery = null;
|
||||
pageDir = Page.RESET;
|
||||
resetSearchTimer();
|
||||
return;
|
||||
}
|
||||
if (serverButton.contains(x, y)) {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
resultList = null;
|
||||
startResultPos.setPosition(0);
|
||||
focusResult = -1;
|
||||
totalResults = 0;
|
||||
page = 0;
|
||||
pageResultTotal = 1;
|
||||
pageDir = Page.RESET;
|
||||
searchResultString = "Loading data from server...";
|
||||
serverIndex = (serverIndex + 1) % SERVERS.length;
|
||||
lastQuery = null;
|
||||
pageDir = Page.RESET;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
return;
|
||||
}
|
||||
@@ -806,6 +869,8 @@ public class DownloadsMenu extends BasicGameState {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
lastQuery = null;
|
||||
pageDir = Page.CURRENT;
|
||||
if (searchQuery != null)
|
||||
searchQuery.interrupt();
|
||||
resetSearchTimer();
|
||||
break;
|
||||
case Input.KEY_F7:
|
||||
@@ -837,7 +902,8 @@ public class DownloadsMenu extends BasicGameState {
|
||||
importButton.resetHover();
|
||||
resetButton.resetHover();
|
||||
rankedButton.resetHover();
|
||||
serverButton.resetHover();
|
||||
serverMenu.activate();
|
||||
serverMenu.reset();
|
||||
focusResult = -1;
|
||||
startResultPos.setPosition(0);
|
||||
startDownloadIndexPos.setPosition(0);
|
||||
@@ -853,6 +919,7 @@ public class DownloadsMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game)
|
||||
throws SlickException {
|
||||
search.setFocus(false);
|
||||
serverMenu.deactivate();
|
||||
SoundController.stopTrack();
|
||||
MusicController.resume();
|
||||
}
|
||||
|
||||
@@ -42,12 +42,16 @@ import itdelatrisu.opsu.objects.GameObject;
|
||||
import itdelatrisu.opsu.objects.Slider;
|
||||
import itdelatrisu.opsu.objects.Spinner;
|
||||
import itdelatrisu.opsu.objects.curves.Curve;
|
||||
import itdelatrisu.opsu.objects.curves.Vec2f;
|
||||
import itdelatrisu.opsu.render.FrameBufferCache;
|
||||
import itdelatrisu.opsu.replay.PlaybackSpeed;
|
||||
import itdelatrisu.opsu.replay.Replay;
|
||||
import itdelatrisu.opsu.replay.ReplayFrame;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
@@ -116,6 +120,15 @@ public class Game extends BasicGameState {
|
||||
/** Hit object approach time, in milliseconds. */
|
||||
private int approachTime;
|
||||
|
||||
/** The amount of time for hit objects to fade in, in milliseconds. */
|
||||
private int fadeInTime;
|
||||
|
||||
/** Decay time for hit objects in the "Hidden" mod, in milliseconds. */
|
||||
private int hiddenDecayTime;
|
||||
|
||||
/** Time before the hit object time by which the objects have completely faded in the "Hidden" mod, in milliseconds. */
|
||||
private int hiddenTimeDiff;
|
||||
|
||||
/** Time offsets for obtaining each hit result (indexed by HIT_* constants). */
|
||||
private int[] hitResultOffset;
|
||||
|
||||
@@ -146,7 +159,7 @@ public class Game extends BasicGameState {
|
||||
countdown2Sound, countdownGoSound;
|
||||
|
||||
/** Mouse coordinates before game paused. */
|
||||
private int pausedMouseX = -1, pausedMouseY = -1;
|
||||
private Vec2f pausedMousePosition;
|
||||
|
||||
/** Track position when game paused. */
|
||||
private int pauseTime = -1;
|
||||
@@ -209,7 +222,7 @@ public class Game extends BasicGameState {
|
||||
private int flashlightRadius;
|
||||
|
||||
/** The cursor coordinates using the "auto" or "relax" mods. */
|
||||
private int autoMouseX = 0, autoMouseY = 0;
|
||||
private Vec2f autoMousePosition;
|
||||
|
||||
/** Whether or not the cursor should be pressed using the "auto" mod. */
|
||||
private boolean autoMousePressed;
|
||||
@@ -220,11 +233,20 @@ public class Game extends BasicGameState {
|
||||
/** Whether the game is currently seeking to a replay position. */
|
||||
private boolean isSeeking;
|
||||
|
||||
/** Music position bar coordinates and dimensions (for replay seeking). */
|
||||
private float musicBarX, musicBarY, musicBarWidth, musicBarHeight;
|
||||
|
||||
/** Music position bar background colors. */
|
||||
private static final Color
|
||||
MUSICBAR_NORMAL = new Color(12, 9, 10, 0.25f),
|
||||
MUSICBAR_HOVER = new Color(12, 9, 10, 0.35f),
|
||||
MUSICBAR_FILL = new Color(255, 255, 255, 0.75f);
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public Game(int state) {
|
||||
this.state = state;
|
||||
@@ -245,6 +267,12 @@ public class Game extends BasicGameState {
|
||||
gOffscreen = offscreen.getGraphics();
|
||||
gOffscreen.setBackground(Color.black);
|
||||
|
||||
// initialize music position bar location
|
||||
musicBarX = width * 0.01f;
|
||||
musicBarY = height * 0.05f;
|
||||
musicBarWidth = Math.max(width * 0.005f, 7);
|
||||
musicBarHeight = height * 0.9f;
|
||||
|
||||
// create the associated GameData object
|
||||
data = new GameData(width, height);
|
||||
}
|
||||
@@ -278,7 +306,7 @@ public class Game extends BasicGameState {
|
||||
else
|
||||
dimLevel = 1f;
|
||||
}
|
||||
if (Options.isDefaultPlayfieldForced() || !beatmap.drawBG(width, height, dimLevel, false)) {
|
||||
if (Options.isDefaultPlayfieldForced() || !beatmap.drawBackground(width, height, dimLevel, false)) {
|
||||
Image playfield = GameImage.PLAYFIELD.getImage();
|
||||
playfield.setAlpha(dimLevel);
|
||||
playfield.draw();
|
||||
@@ -290,32 +318,31 @@ public class Game extends BasicGameState {
|
||||
|
||||
// "auto" and "autopilot" mods: move cursor automatically
|
||||
// TODO: this should really be in update(), not render()
|
||||
autoMouseX = width / 2;
|
||||
autoMouseY = height / 2;
|
||||
autoMousePosition.set(width / 2, height / 2);
|
||||
autoMousePressed = false;
|
||||
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
||||
float[] autoXY = null;
|
||||
Vec2f autoPoint = null;
|
||||
if (isLeadIn()) {
|
||||
// lead-in
|
||||
float progress = Math.max((float) (leadInTime - beatmap.audioLeadIn) / approachTime, 0f);
|
||||
autoMouseY = (int) (height / (2f - progress));
|
||||
autoMousePosition.y = height / (2f - progress);
|
||||
} else if (objectIndex == 0 && trackPosition < firstObjectTime) {
|
||||
// before first object
|
||||
timeDiff = firstObjectTime - trackPosition;
|
||||
if (timeDiff < approachTime) {
|
||||
float[] xy = gameObjects[0].getPointAt(trackPosition);
|
||||
autoXY = getPointAt(autoMouseX, autoMouseY, xy[0], xy[1], 1f - ((float) timeDiff / approachTime));
|
||||
Vec2f point = gameObjects[0].getPointAt(trackPosition);
|
||||
autoPoint = getPointAt(autoMousePosition.x, autoMousePosition.y, point.x, point.y, 1f - ((float) timeDiff / approachTime));
|
||||
}
|
||||
} else if (objectIndex < beatmap.objects.length) {
|
||||
// normal object
|
||||
int objectTime = beatmap.objects[objectIndex].getTime();
|
||||
if (trackPosition < objectTime) {
|
||||
float[] xyStart = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||
Vec2f startPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||
int startTime = gameObjects[objectIndex - 1].getEndTime();
|
||||
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size()) {
|
||||
// starting a break: keep cursor at previous hit object position
|
||||
if (breakTime > 0 || objectTime > beatmap.breaks.get(breakIndex))
|
||||
autoXY = xyStart;
|
||||
autoPoint = startPoint;
|
||||
|
||||
// after a break ends: move startTime to break end time
|
||||
else if (breakIndex > 1) {
|
||||
@@ -324,10 +351,10 @@ public class Game extends BasicGameState {
|
||||
startTime = lastBreakEndTime;
|
||||
}
|
||||
}
|
||||
if (autoXY == null) {
|
||||
float[] xyEnd = gameObjects[objectIndex].getPointAt(trackPosition);
|
||||
if (autoPoint == null) {
|
||||
Vec2f endPoint = gameObjects[objectIndex].getPointAt(trackPosition);
|
||||
int totalTime = objectTime - startTime;
|
||||
autoXY = getPointAt(xyStart[0], xyStart[1], xyEnd[0], xyEnd[1], (float) (trackPosition - startTime) / totalTime);
|
||||
autoPoint = getPointAt(startPoint.x, startPoint.y, endPoint.x, endPoint.y, (float) (trackPosition - startTime) / totalTime);
|
||||
|
||||
// hit circles: show a mouse press
|
||||
int offset300 = hitResultOffset[GameData.HIT_300];
|
||||
@@ -336,19 +363,17 @@ public class Game extends BasicGameState {
|
||||
autoMousePressed = true;
|
||||
}
|
||||
} else {
|
||||
autoXY = gameObjects[objectIndex].getPointAt(trackPosition);
|
||||
autoPoint = gameObjects[objectIndex].getPointAt(trackPosition);
|
||||
autoMousePressed = true;
|
||||
}
|
||||
} else {
|
||||
// last object
|
||||
autoXY = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||
autoPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||
}
|
||||
|
||||
// set mouse coordinates
|
||||
if (autoXY != null) {
|
||||
autoMouseX = (int) autoXY[0];
|
||||
autoMouseY = (int) autoXY[1];
|
||||
}
|
||||
if (autoPoint != null)
|
||||
autoMousePosition.set(autoPoint.x, autoPoint.y);
|
||||
}
|
||||
|
||||
// "flashlight" mod: restricted view of hit objects around cursor
|
||||
@@ -366,12 +391,12 @@ public class Game extends BasicGameState {
|
||||
g.setDrawMode(Graphics.MODE_ALPHA_MAP);
|
||||
g.clearAlphaMap();
|
||||
int mouseX, mouseY;
|
||||
if (pauseTime > -1 && pausedMouseX > -1 && pausedMouseY > -1) {
|
||||
mouseX = pausedMouseX;
|
||||
mouseY = pausedMouseY;
|
||||
if (pauseTime > -1 && pausedMousePosition != null) {
|
||||
mouseX = (int) pausedMousePosition.x;
|
||||
mouseY = (int) pausedMousePosition.y;
|
||||
} else if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
||||
mouseX = autoMouseX;
|
||||
mouseY = autoMouseY;
|
||||
mouseX = (int) autoMousePosition.x;
|
||||
mouseY = (int) autoMousePosition.y;
|
||||
} else if (isReplay) {
|
||||
mouseX = replayX;
|
||||
mouseY = replayY;
|
||||
@@ -455,15 +480,15 @@ public class Game extends BasicGameState {
|
||||
GameImage.SCOREBAR_BG.getImage().getHeight(),
|
||||
GameImage.SCOREBAR_KI.getImage().getHeight()
|
||||
);
|
||||
float oldAlpha = Utils.COLOR_WHITE_FADE.a;
|
||||
float oldAlpha = Colors.WHITE_FADE.a;
|
||||
if (timeDiff < -500)
|
||||
Utils.COLOR_WHITE_FADE.a = (1000 + timeDiff) / 500f;
|
||||
Utils.FONT_MEDIUM.drawString(
|
||||
Colors.WHITE_FADE.a = (1000 + timeDiff) / 500f;
|
||||
Fonts.MEDIUM.drawString(
|
||||
2 + (width / 100), retryHeight,
|
||||
String.format("%d retries and counting...", retries),
|
||||
Utils.COLOR_WHITE_FADE
|
||||
Colors.WHITE_FADE
|
||||
);
|
||||
Utils.COLOR_WHITE_FADE.a = oldAlpha;
|
||||
Colors.WHITE_FADE.a = oldAlpha;
|
||||
}
|
||||
|
||||
if (isLeadIn())
|
||||
@@ -525,28 +550,40 @@ public class Game extends BasicGameState {
|
||||
if (isReplay || GameMod.AUTO.isActive())
|
||||
playbackSpeed.getButton().draw();
|
||||
|
||||
// draw music position bar (for replay seeking)
|
||||
if (isReplay && Options.isReplaySeekingEnabled()) {
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? MUSICBAR_HOVER : MUSICBAR_NORMAL);
|
||||
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
|
||||
if (!isLeadIn()) {
|
||||
g.setColor(MUSICBAR_FILL);
|
||||
float musicBarPosition = Math.min((float) trackPosition / beatmap.endTime, 1f);
|
||||
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight * musicBarPosition, 4);
|
||||
}
|
||||
}
|
||||
|
||||
// returning from pause screen
|
||||
if (pauseTime > -1 && pausedMouseX > -1 && pausedMouseY > -1) {
|
||||
if (pauseTime > -1 && pausedMousePosition != null) {
|
||||
// darken the screen
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
// draw glowing hit select circle and pulse effect
|
||||
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth();
|
||||
Image cursorCircle = GameImage.HITCIRCLE_SELECT.getImage().getScaledCopy(circleRadius, circleRadius);
|
||||
int circleDiameter = GameImage.HITCIRCLE.getImage().getWidth();
|
||||
Image cursorCircle = GameImage.HITCIRCLE_SELECT.getImage().getScaledCopy(circleDiameter, circleDiameter);
|
||||
cursorCircle.setAlpha(1.0f);
|
||||
cursorCircle.drawCentered(pausedMouseX, pausedMouseY);
|
||||
cursorCircle.drawCentered(pausedMousePosition.x, pausedMousePosition.y);
|
||||
Image cursorCirclePulse = cursorCircle.getScaledCopy(1f + pausePulse);
|
||||
cursorCirclePulse.setAlpha(1f - pausePulse);
|
||||
cursorCirclePulse.drawCentered(pausedMouseX, pausedMouseY);
|
||||
cursorCirclePulse.drawCentered(pausedMousePosition.x, pausedMousePosition.y);
|
||||
}
|
||||
|
||||
if (isReplay)
|
||||
UI.draw(g, replayX, replayY, replayKeyPressed);
|
||||
else if (GameMod.AUTO.isActive())
|
||||
UI.draw(g, autoMouseX, autoMouseY, autoMousePressed);
|
||||
UI.draw(g, (int) autoMousePosition.x, (int) autoMousePosition.y, autoMousePressed);
|
||||
else if (GameMod.AUTOPILOT.isActive())
|
||||
UI.draw(g, autoMouseX, autoMouseY, Utils.isGameKeyPressed());
|
||||
UI.draw(g, (int) autoMousePosition.x, (int) autoMousePosition.y, Utils.isGameKeyPressed());
|
||||
else
|
||||
UI.draw(g);
|
||||
}
|
||||
@@ -564,8 +601,7 @@ public class Game extends BasicGameState {
|
||||
// returning from pause screen: must click previous mouse position
|
||||
if (pauseTime > -1) {
|
||||
// paused during lead-in or break, or "relax" or "autopilot": continue immediately
|
||||
if ((pausedMouseX < 0 && pausedMouseY < 0) ||
|
||||
(GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) {
|
||||
if (pausedMousePosition == null || (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) {
|
||||
pauseTime = -1;
|
||||
if (!isLeadIn())
|
||||
MusicController.resume();
|
||||
@@ -603,6 +639,17 @@ public class Game extends BasicGameState {
|
||||
return;
|
||||
}
|
||||
|
||||
// "Easy" mod: multiple "lives"
|
||||
if (GameMod.EASY.isActive() && deathTime > -1) {
|
||||
if (data.getHealth() < 99f) {
|
||||
data.changeHealth(delta / 10f);
|
||||
data.updateDisplays(delta);
|
||||
return;
|
||||
}
|
||||
MusicController.resume();
|
||||
deathTime = -1;
|
||||
}
|
||||
|
||||
// normal game update
|
||||
if (!isReplay)
|
||||
addReplayFrameAndRun(mouseX, mouseY, lastKeysPressed, trackPosition);
|
||||
@@ -613,7 +660,7 @@ public class Game extends BasicGameState {
|
||||
if (replayIndex >= replay.frames.length)
|
||||
updateGame(replayX, replayY, delta, MusicController.getPosition(), lastKeysPressed);
|
||||
|
||||
//TODO probably should to disable sounds then reseek to the new position
|
||||
// seeking to a position earlier than original track position
|
||||
if (isSeeking && replayIndex - 1 >= 1 && replayIndex < replay.frames.length &&
|
||||
trackPosition < replay.frames[replayIndex - 1].getTime()) {
|
||||
replayIndex = 0;
|
||||
@@ -633,7 +680,6 @@ public class Game extends BasicGameState {
|
||||
timingPointIndex++;
|
||||
}
|
||||
}
|
||||
isSeeking = false;
|
||||
}
|
||||
|
||||
// update and run replay frames
|
||||
@@ -648,6 +694,12 @@ public class Game extends BasicGameState {
|
||||
}
|
||||
mouseX = replayX;
|
||||
mouseY = replayY;
|
||||
|
||||
// unmute sounds
|
||||
if (isSeeking) {
|
||||
isSeeking = false;
|
||||
SoundController.mute(false);
|
||||
}
|
||||
}
|
||||
|
||||
data.updateDisplays(delta);
|
||||
@@ -662,16 +714,6 @@ public class Game extends BasicGameState {
|
||||
* @param keys the keys that are pressed
|
||||
*/
|
||||
private void updateGame(int mouseX, int mouseY, int delta, int trackPosition, int keys) {
|
||||
// "Easy" mod: multiple "lives"
|
||||
if (GameMod.EASY.isActive() && deathTime > -1) {
|
||||
if (data.getHealth() < 99f)
|
||||
data.changeHealth(delta / 10f);
|
||||
else {
|
||||
MusicController.resume();
|
||||
deathTime = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// map complete!
|
||||
if (objectIndex >= gameObjects.length || (MusicController.trackEnded() && objectIndex > 0)) {
|
||||
// track ended before last object was processed: force a hit result
|
||||
@@ -699,6 +741,7 @@ public class Game extends BasicGameState {
|
||||
r.save();
|
||||
}
|
||||
ScoreData score = data.getScoreData(beatmap);
|
||||
data.setGameplay(!isReplay);
|
||||
|
||||
// add score to database
|
||||
if (!unranked && !isReplay)
|
||||
@@ -745,8 +788,7 @@ public class Game extends BasicGameState {
|
||||
// pause game if focus lost
|
||||
if (!container.hasFocus() && !GameMod.AUTO.isActive() && !isReplay) {
|
||||
if (pauseTime < 0) {
|
||||
pausedMouseX = mouseX;
|
||||
pausedMouseY = mouseY;
|
||||
pausedMousePosition = new Vec2f(mouseX, mouseY);
|
||||
pausePulse = 0f;
|
||||
}
|
||||
if (MusicController.isPlaying() || isLeadIn())
|
||||
@@ -819,8 +861,7 @@ public class Game extends BasicGameState {
|
||||
|
||||
// pause game
|
||||
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) {
|
||||
pausedMouseX = mouseX;
|
||||
pausedMouseY = mouseY;
|
||||
pausedMousePosition = new Vec2f(mouseX, mouseY);
|
||||
pausePulse = 0f;
|
||||
}
|
||||
if (MusicController.isPlaying() || isLeadIn())
|
||||
@@ -888,6 +929,13 @@ public class Game extends BasicGameState {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Input.KEY_F:
|
||||
// change playback speed
|
||||
if (isReplay || GameMod.AUTO.isActive()) {
|
||||
playbackSpeed = playbackSpeed.next();
|
||||
MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier());
|
||||
}
|
||||
break;
|
||||
case Input.KEY_UP:
|
||||
UI.changeVolume(1);
|
||||
break;
|
||||
@@ -923,9 +971,10 @@ public class Game extends BasicGameState {
|
||||
MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier());
|
||||
}
|
||||
|
||||
// TODO
|
||||
else if (!GameMod.AUTO.isActive() && y < 50) {
|
||||
float pos = (float) x / container.getWidth() * beatmap.endTime;
|
||||
// replay seeking
|
||||
else if (Options.isReplaySeekingEnabled() && !GameMod.AUTO.isActive() && musicPositionBarContains(x, y)) {
|
||||
SoundController.mute(true); // mute sounds while seeking
|
||||
float pos = (y - musicBarY) / musicBarHeight * beatmap.endTime;
|
||||
MusicController.setPosition((int) pos);
|
||||
isSeeking = true;
|
||||
}
|
||||
@@ -939,8 +988,7 @@ public class Game extends BasicGameState {
|
||||
if (button == Input.MOUSE_MIDDLE_BUTTON && !Options.isMouseWheelDisabled()) {
|
||||
int trackPosition = MusicController.getPosition();
|
||||
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) {
|
||||
pausedMouseX = x;
|
||||
pausedMouseY = y;
|
||||
pausedMousePosition = new Vec2f(x, y);
|
||||
pausePulse = 0f;
|
||||
}
|
||||
if (MusicController.isPlaying() || isLeadIn())
|
||||
@@ -969,13 +1017,12 @@ public class Game extends BasicGameState {
|
||||
private void gameKeyPressed(int keys, int x, int y, int trackPosition) {
|
||||
// returning from pause screen
|
||||
if (pauseTime > -1) {
|
||||
double distance = Math.hypot(pausedMouseX - x, pausedMouseY - y);
|
||||
double distance = Math.hypot(pausedMousePosition.x - x, pausedMousePosition.y - y);
|
||||
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth() / 2;
|
||||
if (distance < circleRadius) {
|
||||
// unpause the game
|
||||
pauseTime = -1;
|
||||
pausedMouseX = -1;
|
||||
pausedMouseY = -1;
|
||||
pausedMousePosition = null;
|
||||
if (!isLeadIn())
|
||||
MusicController.resume();
|
||||
}
|
||||
@@ -1065,6 +1112,15 @@ public class Game extends BasicGameState {
|
||||
|
||||
// restart the game
|
||||
if (restart != Restart.FALSE) {
|
||||
// load mods
|
||||
if (isReplay) {
|
||||
previousMods = GameMod.getModState();
|
||||
GameMod.loadModState(replay.mods);
|
||||
}
|
||||
|
||||
data.setGameplay(true);
|
||||
|
||||
// check restart state
|
||||
if (restart == Restart.NEW) {
|
||||
// new game
|
||||
loadImages();
|
||||
@@ -1149,10 +1205,6 @@ public class Game extends BasicGameState {
|
||||
|
||||
// load replay frames
|
||||
if (isReplay) {
|
||||
// load mods
|
||||
previousMods = GameMod.getModState();
|
||||
GameMod.loadModState(replay.mods);
|
||||
|
||||
// load initial data
|
||||
replayX = container.getWidth() / 2;
|
||||
replayY = container.getHeight() / 2;
|
||||
@@ -1188,6 +1240,8 @@ public class Game extends BasicGameState {
|
||||
MusicController.setPosition(0);
|
||||
MusicController.setPitch(GameMod.getSpeedMultiplier());
|
||||
MusicController.pause();
|
||||
|
||||
SoundController.mute(false);
|
||||
}
|
||||
|
||||
skipButton.resetHover();
|
||||
@@ -1242,10 +1296,10 @@ public class Game extends BasicGameState {
|
||||
final int followPointInterval = container.getHeight() / 14;
|
||||
int lastObjectEndTime = gameObjects[lastObjectIndex].getEndTime() + 1;
|
||||
int objectStartTime = beatmap.objects[index].getTime();
|
||||
float[] startXY = gameObjects[lastObjectIndex].getPointAt(lastObjectEndTime);
|
||||
float[] endXY = gameObjects[index].getPointAt(objectStartTime);
|
||||
float xDiff = endXY[0] - startXY[0];
|
||||
float yDiff = endXY[1] - startXY[1];
|
||||
Vec2f startPoint = gameObjects[lastObjectIndex].getPointAt(lastObjectEndTime);
|
||||
Vec2f endPoint = gameObjects[index].getPointAt(objectStartTime);
|
||||
float xDiff = endPoint.x - startPoint.x;
|
||||
float yDiff = endPoint.y - startPoint.y;
|
||||
float dist = (float) Math.hypot(xDiff, yDiff);
|
||||
int numPoints = (int) ((dist - GameImage.HITCIRCLE.getImage().getWidth()) / followPointInterval);
|
||||
if (numPoints > 0) {
|
||||
@@ -1266,8 +1320,8 @@ public class Game extends BasicGameState {
|
||||
float step = 1f / (numPoints + 1);
|
||||
float t = step;
|
||||
for (int i = 0; i < numPoints; i++) {
|
||||
float x = startXY[0] + xDiff * t;
|
||||
float y = startXY[1] + yDiff * t;
|
||||
float x = startPoint.x + xDiff * t;
|
||||
float y = startPoint.y + yDiff * t;
|
||||
float nextT = t + step;
|
||||
if (lastObjectIndex < objectIndex) { // fade the previous trail
|
||||
if (progress < nextT) {
|
||||
@@ -1321,8 +1375,7 @@ public class Game extends BasicGameState {
|
||||
timingPointIndex = 0;
|
||||
beatLengthBase = beatLength = 1;
|
||||
pauseTime = -1;
|
||||
pausedMouseX = -1;
|
||||
pausedMouseY = -1;
|
||||
pausedMousePosition = null;
|
||||
countdownReadySound = false;
|
||||
countdown3Sound = false;
|
||||
countdown1Sound = false;
|
||||
@@ -1333,8 +1386,7 @@ public class Game extends BasicGameState {
|
||||
deathTime = -1;
|
||||
replayFrames = null;
|
||||
lastReplayTime = 0;
|
||||
autoMouseX = 0;
|
||||
autoMouseY = 0;
|
||||
autoMousePosition = new Vec2f();
|
||||
autoMousePressed = false;
|
||||
flashlightRadius = container.getHeight() * 2 / 3;
|
||||
|
||||
@@ -1376,9 +1428,9 @@ public class Game extends BasicGameState {
|
||||
// set images
|
||||
File parent = beatmap.getFile().getParentFile();
|
||||
for (GameImage img : GameImage.values()) {
|
||||
if (img.isSkinnable()) {
|
||||
if (img.isBeatmapSkinnable()) {
|
||||
img.setDefaultImage();
|
||||
img.setSkinImage(parent);
|
||||
img.setBeatmapSkinImage(parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1390,6 +1442,8 @@ public class Game extends BasicGameState {
|
||||
Image skip = GameImage.SKIP.getImage();
|
||||
skipButton = new MenuButton(skip, width - skip.getWidth() / 2f, height - (skip.getHeight() / 2f));
|
||||
}
|
||||
skipButton.setHoverAnimationDuration(350);
|
||||
skipButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
skipButton.setHoverExpand(1.1f, MenuButton.Expand.UP_LEFT);
|
||||
|
||||
// load other images...
|
||||
@@ -1420,14 +1474,15 @@ public class Game extends BasicGameState {
|
||||
|
||||
// Stack modifier scales with hit object size
|
||||
// StackOffset = HitObjectRadius / 10
|
||||
int diameter = (int) (104 - (circleSize * 8));
|
||||
//int diameter = (int) (104 - (circleSize * 8));
|
||||
float diameter = 108.848f - (circleSize * 8.9646f);
|
||||
HitObject.setStackOffset(diameter * STACK_OFFSET_MODIFIER);
|
||||
|
||||
// initialize objects
|
||||
Circle.init(container, circleSize);
|
||||
Slider.init(container, circleSize, beatmap);
|
||||
Circle.init(container, diameter);
|
||||
Slider.init(container, diameter, beatmap);
|
||||
Spinner.init(container, overallDifficulty);
|
||||
Curve.init(container.getWidth(), container.getHeight(), circleSize, (Options.isBeatmapSkinIgnored()) ?
|
||||
Curve.init(container.getWidth(), container.getHeight(), diameter, (Options.isBeatmapSkinIgnored()) ?
|
||||
Options.getSkin().getSliderBorderColor() : beatmap.getSliderBorderColor());
|
||||
|
||||
// approachRate (hit object approach time)
|
||||
@@ -1438,9 +1493,9 @@ public class Game extends BasicGameState {
|
||||
|
||||
// overallDifficulty (hit result time offsets)
|
||||
hitResultOffset = new int[GameData.HIT_MAX];
|
||||
hitResultOffset[GameData.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
||||
hitResultOffset[GameData.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
||||
hitResultOffset[GameData.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
||||
hitResultOffset[GameData.HIT_300] = (int) (79.5f - (overallDifficulty * 6));
|
||||
hitResultOffset[GameData.HIT_100] = (int) (139.5f - (overallDifficulty * 8));
|
||||
hitResultOffset[GameData.HIT_50] = (int) (199.5f - (overallDifficulty * 10));
|
||||
hitResultOffset[GameData.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
||||
//final float mult = 0.608f;
|
||||
//hitResultOffset[GameData.HIT_300] = (int) ((128 - (overallDifficulty * 9.6)) * mult);
|
||||
@@ -1454,6 +1509,14 @@ public class Game extends BasicGameState {
|
||||
|
||||
// difficulty multiplier (scoring)
|
||||
data.calculateDifficultyMultiplier(beatmap.HPDrainRate, beatmap.circleSize, beatmap.overallDifficulty);
|
||||
|
||||
// hit object fade-in time (TODO: formula)
|
||||
fadeInTime = Math.min(375, (int) (approachTime / 2.5f));
|
||||
|
||||
// fade times ("Hidden" mod)
|
||||
// TODO: find the actual formulas for this
|
||||
hiddenDecayTime = (int) (approachTime / 3.6f);
|
||||
hiddenTimeDiff = (int) (approachTime / 3.3f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1477,6 +1540,22 @@ public class Game extends BasicGameState {
|
||||
*/
|
||||
public int getApproachTime() { return approachTime; }
|
||||
|
||||
/**
|
||||
* Returns the amount of time for hit objects to fade in, in milliseconds.
|
||||
*/
|
||||
public int getFadeInTime() { return fadeInTime; }
|
||||
|
||||
/**
|
||||
* Returns the object decay time in the "Hidden" mod, in milliseconds.
|
||||
*/
|
||||
public int getHiddenDecayTime() { return hiddenDecayTime; }
|
||||
|
||||
/**
|
||||
* Returns the time before the hit object time by which the objects have
|
||||
* completely faded in the "Hidden" mod, in milliseconds.
|
||||
*/
|
||||
public int getHiddenTimeDiff() { return hiddenTimeDiff; }
|
||||
|
||||
/**
|
||||
* Returns an array of hit result offset times, in milliseconds (indexed by GameData.HIT_* constants).
|
||||
*/
|
||||
@@ -1536,8 +1615,8 @@ public class Game extends BasicGameState {
|
||||
public synchronized void addReplayFrameAndRun(int x, int y, int keys, int time){
|
||||
// "auto" and "autopilot" mods: use automatic cursor coordinates
|
||||
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
||||
x = autoMouseX;
|
||||
y = autoMouseY;
|
||||
x = (int) autoMousePosition.x;
|
||||
y = (int) autoMousePosition.y;
|
||||
}
|
||||
|
||||
ReplayFrame frame = addReplayFrame(x, y, keys, time);
|
||||
@@ -1611,17 +1690,13 @@ public class Game extends BasicGameState {
|
||||
* @param endX the ending x coordinate
|
||||
* @param endY the ending y coordinate
|
||||
* @param t the t value [0, 1]
|
||||
* @return the [x,y] coordinates
|
||||
* @return the position vector
|
||||
*/
|
||||
private float[] getPointAt(float startX, float startY, float endX, float endY, float t) {
|
||||
private Vec2f getPointAt(float startX, float startY, float endX, float endY, float t) {
|
||||
// "autopilot" mod: move quicker between objects
|
||||
if (GameMod.AUTOPILOT.isActive())
|
||||
t = Utils.clamp(t * 2f, 0f, 1f);
|
||||
|
||||
float[] xy = new float[2];
|
||||
xy[0] = startX + (endX - startX) * t;
|
||||
xy[1] = startY + (endY - startY) * t;
|
||||
return xy;
|
||||
return new Vec2f(startX + (endX - startX) * t, startY + (endY - startY) * t);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1715,9 +1790,9 @@ public class Game extends BasicGameState {
|
||||
// possible special case: if slider end in the stack,
|
||||
// all next hit objects in stack move right down
|
||||
if (hitObjectN.isSlider()) {
|
||||
float[] p1 = gameObjects[i].getPointAt(hitObjectI.getTime());
|
||||
float[] p2 = gameObjects[n].getPointAt(gameObjects[n].getEndTime());
|
||||
float distance = Utils.distance(p1[0], p1[1], p2[0], p2[1]);
|
||||
Vec2f p1 = gameObjects[i].getPointAt(hitObjectI.getTime());
|
||||
Vec2f p2 = gameObjects[n].getPointAt(gameObjects[n].getEndTime());
|
||||
float distance = Utils.distance(p1.x, p1.y, p2.x, p2.y);
|
||||
|
||||
// check if hit object part of this stack
|
||||
if (distance < STACK_LENIENCE * HitObject.getXMultiplier()) {
|
||||
@@ -1725,7 +1800,7 @@ public class Game extends BasicGameState {
|
||||
for (int j = n + 1; j <= i; j++) {
|
||||
HitObject hitObjectJ = beatmap.objects[j];
|
||||
p1 = gameObjects[j].getPointAt(hitObjectJ.getTime());
|
||||
distance = Utils.distance(p1[0], p1[1], p2[0], p2[1]);
|
||||
distance = Utils.distance(p1.x, p1.y, p2.x, p2.y);
|
||||
|
||||
// hit object below slider end
|
||||
if (distance < STACK_LENIENCE * HitObject.getXMultiplier())
|
||||
@@ -1753,4 +1828,14 @@ public class Game extends BasicGameState {
|
||||
gameObjects[i].updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the coordinates are within the music position bar bounds.
|
||||
* @param cx the x coordinate
|
||||
* @param cy the y coordinate
|
||||
*/
|
||||
private boolean musicPositionBarContains(float cx, float cy) {
|
||||
return ((cx > musicBarX && cx < musicBarX + musicBarWidth) &&
|
||||
(cy > musicBarY && cy < musicBarY + musicBarHeight));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.newdawn.slick.Color;
|
||||
@@ -61,7 +62,7 @@ public class GamePauseMenu extends BasicGameState {
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
private Game gameState;
|
||||
|
||||
public GamePauseMenu(int state) {
|
||||
@@ -86,10 +87,10 @@ public class GamePauseMenu extends BasicGameState {
|
||||
|
||||
// don't draw default background if button skinned and background unskinned
|
||||
boolean buttonsSkinned =
|
||||
GameImage.PAUSE_CONTINUE.hasSkinImage() ||
|
||||
GameImage.PAUSE_RETRY.hasSkinImage() ||
|
||||
GameImage.PAUSE_BACK.hasSkinImage();
|
||||
if (!buttonsSkinned || bg.hasSkinImage())
|
||||
GameImage.PAUSE_CONTINUE.hasBeatmapSkinImage() ||
|
||||
GameImage.PAUSE_RETRY.hasBeatmapSkinImage() ||
|
||||
GameImage.PAUSE_BACK.hasBeatmapSkinImage();
|
||||
if (!buttonsSkinned || bg.hasBeatmapSkinImage())
|
||||
bg.getImage().draw();
|
||||
else
|
||||
g.setBackground(Color.black);
|
||||
@@ -133,7 +134,7 @@ public class GamePauseMenu extends BasicGameState {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
|
||||
if (UI.getCursor().isSkinned())
|
||||
if (UI.getCursor().isBeatmapSkinned())
|
||||
UI.getCursor().reset();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
} else {
|
||||
@@ -187,7 +188,7 @@ public class GamePauseMenu extends BasicGameState {
|
||||
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
|
||||
else
|
||||
MusicController.resume();
|
||||
if (UI.getCursor().isSkinned())
|
||||
if (UI.getCursor().isBeatmapSkinned())
|
||||
UI.getCursor().reset();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
}
|
||||
@@ -227,6 +228,14 @@ public class GamePauseMenu extends BasicGameState {
|
||||
continueButton = new MenuButton(GameImage.PAUSE_CONTINUE.getImage(), width / 2f, height * 0.25f);
|
||||
retryButton = new MenuButton(GameImage.PAUSE_RETRY.getImage(), width / 2f, height * 0.5f);
|
||||
backButton = new MenuButton(GameImage.PAUSE_BACK.getImage(), width / 2f, height * 0.75f);
|
||||
final int buttonAnimationDuration = 300;
|
||||
continueButton.setHoverAnimationDuration(buttonAnimationDuration);
|
||||
retryButton.setHoverAnimationDuration(buttonAnimationDuration);
|
||||
backButton.setHoverAnimationDuration(buttonAnimationDuration);
|
||||
final AnimationEquation buttonAnimationEquation = AnimationEquation.IN_OUT_BACK;
|
||||
continueButton.setHoverAnimationEquation(buttonAnimationEquation);
|
||||
retryButton.setHoverAnimationEquation(buttonAnimationEquation);
|
||||
backButton.setHoverAnimationEquation(buttonAnimationEquation);
|
||||
continueButton.setHoverExpand();
|
||||
retryButton.setHoverExpand();
|
||||
backButton.setHoverExpand();
|
||||
|
||||
@@ -20,6 +20,7 @@ package itdelatrisu.opsu.states;
|
||||
|
||||
import itdelatrisu.opsu.GameData;
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.GameMod;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
@@ -68,7 +69,7 @@ public class GameRanking extends BasicGameState {
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private int state;
|
||||
private final int state;
|
||||
private Input input;
|
||||
|
||||
public GameRanking(int state) {
|
||||
@@ -105,7 +106,7 @@ public class GameRanking extends BasicGameState {
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
|
||||
// background
|
||||
if (!beatmap.drawBG(width, height, 0.7f, true))
|
||||
if (!beatmap.drawBackground(width, height, 0.7f, true))
|
||||
GameImage.PLAYFIELD.getImage().draw(0,0);
|
||||
|
||||
// ranking screen elements
|
||||
@@ -113,7 +114,7 @@ public class GameRanking extends BasicGameState {
|
||||
|
||||
// buttons
|
||||
replayButton.draw();
|
||||
if (data.isGameplay())
|
||||
if (data.isGameplay() && !GameMod.AUTO.isActive())
|
||||
retryButton.draw();
|
||||
UI.getBackButton().draw();
|
||||
|
||||
@@ -175,7 +176,8 @@ public class GameRanking extends BasicGameState {
|
||||
// replay
|
||||
Game gameState = (Game) game.getState(Opsu.STATE_GAME);
|
||||
boolean returnToGame = false;
|
||||
if (replayButton.contains(x, y)) {
|
||||
boolean replayButtonPressed = replayButton.contains(x, y);
|
||||
if (replayButtonPressed && !(data.isGameplay() && GameMod.AUTO.isActive())) {
|
||||
Replay r = data.getReplay(null, null);
|
||||
if (r != null) {
|
||||
try {
|
||||
@@ -194,7 +196,9 @@ public class GameRanking extends BasicGameState {
|
||||
}
|
||||
|
||||
// retry
|
||||
else if (data.isGameplay() && retryButton.contains(x, y)) {
|
||||
else if (data.isGameplay() &&
|
||||
(!GameMod.AUTO.isActive() && retryButton.contains(x, y)) ||
|
||||
(GameMod.AUTO.isActive() && replayButtonPressed)) {
|
||||
gameState.setReplay(null);
|
||||
gameState.setRestart(Game.Restart.MANUAL);
|
||||
returnToGame = true;
|
||||
@@ -221,7 +225,7 @@ public class GameRanking extends BasicGameState {
|
||||
} else {
|
||||
SoundController.playSound(SoundEffect.APPLAUSE);
|
||||
retryButton.resetHover();
|
||||
replayButton.setY(replayY);
|
||||
replayButton.setY(!GameMod.AUTO.isActive() ? replayY : retryY);
|
||||
}
|
||||
replayButton.resetHover();
|
||||
}
|
||||
@@ -239,12 +243,11 @@ public class GameRanking extends BasicGameState {
|
||||
*/
|
||||
private void returnToSongMenu() {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
if (data.isGameplay()) {
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
if (data.isGameplay())
|
||||
songMenu.resetTrackOnLoad();
|
||||
}
|
||||
if (UI.getCursor().isSkinned())
|
||||
songMenu.resetGameDataOnLoad();
|
||||
if (UI.getCursor().isBeatmapSkinned())
|
||||
UI.getCursor().reset();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
}
|
||||
|
||||
@@ -31,9 +31,13 @@ import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
||||
import itdelatrisu.opsu.downloads.Updater;
|
||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.MenuButton.Expand;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
@@ -61,7 +65,7 @@ import org.newdawn.slick.state.transition.FadeOutTransition;
|
||||
*/
|
||||
public class MainMenu extends BasicGameState {
|
||||
/** Idle time, in milliseconds, before returning the logo to its original position. */
|
||||
private static final short MOVE_DELAY = 5000;
|
||||
private static final short LOGO_IDLE_DELAY = 10000;
|
||||
|
||||
/** Max alpha level of the menu background. */
|
||||
private static final float BG_MAX_ALPHA = 0.9f;
|
||||
@@ -69,12 +73,21 @@ public class MainMenu extends BasicGameState {
|
||||
/** Logo button that reveals other buttons on click. */
|
||||
private MenuButton logo;
|
||||
|
||||
/** Whether or not the logo has been clicked. */
|
||||
private boolean logoClicked = false;
|
||||
/** Logo states. */
|
||||
private enum LogoState { DEFAULT, OPENING, OPEN, CLOSING }
|
||||
|
||||
/** Current logo state. */
|
||||
private LogoState logoState = LogoState.DEFAULT;
|
||||
|
||||
/** Delay timer, in milliseconds, before starting to move the logo back to the center. */
|
||||
private int logoTimer = 0;
|
||||
|
||||
/** Logo horizontal offset for opening and closing actions. */
|
||||
private AnimatedValue logoOpen, logoClose;
|
||||
|
||||
/** Logo button alpha levels. */
|
||||
private AnimatedValue logoButtonAlpha;
|
||||
|
||||
/** Main "Play" and "Exit" buttons. */
|
||||
private MenuButton playButton, exitButton;
|
||||
|
||||
@@ -87,8 +100,8 @@ public class MainMenu extends BasicGameState {
|
||||
/** Button linking to repository. */
|
||||
private MenuButton repoButton;
|
||||
|
||||
/** Button for installing updates. */
|
||||
private MenuButton updateButton;
|
||||
/** Buttons for installing updates. */
|
||||
private MenuButton updateButton, restartButton;
|
||||
|
||||
/** Application start time, for drawing the total running time. */
|
||||
private long programStartTime;
|
||||
@@ -97,7 +110,7 @@ public class MainMenu extends BasicGameState {
|
||||
private Stack<Integer> previous;
|
||||
|
||||
/** Background alpha level (for fade-in effect). */
|
||||
private float bgAlpha = 0f;
|
||||
private AnimatedValue bgAlpha = new AnimatedValue(1100, 0f, BG_MAX_ALPHA, AnimationEquation.LINEAR);
|
||||
|
||||
/** Whether or not a notification was already sent upon entering. */
|
||||
private boolean enterNotification = false;
|
||||
@@ -105,16 +118,11 @@ public class MainMenu extends BasicGameState {
|
||||
/** Music position bar coordinates and dimensions. */
|
||||
private float musicBarX, musicBarY, musicBarWidth, musicBarHeight;
|
||||
|
||||
/** Music position bar background colors. */
|
||||
private static final Color
|
||||
BG_NORMAL = new Color(0, 0, 0, 0.25f),
|
||||
BG_HOVER = new Color(0, 0, 0, 0.5f);
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public MainMenu(int state) {
|
||||
this.state = state;
|
||||
@@ -145,9 +153,18 @@ public class MainMenu extends BasicGameState {
|
||||
exitButton = new MenuButton(exitImg,
|
||||
width * 0.75f - exitOffset, (height / 2) + (exitImg.getHeight() / 2f)
|
||||
);
|
||||
logo.setHoverExpand(1.05f);
|
||||
playButton.setHoverExpand(1.05f);
|
||||
exitButton.setHoverExpand(1.05f);
|
||||
final int logoAnimationDuration = 350;
|
||||
logo.setHoverAnimationDuration(logoAnimationDuration);
|
||||
playButton.setHoverAnimationDuration(logoAnimationDuration);
|
||||
exitButton.setHoverAnimationDuration(logoAnimationDuration);
|
||||
final AnimationEquation logoAnimationEquation = AnimationEquation.IN_OUT_BACK;
|
||||
logo.setHoverAnimationEquation(logoAnimationEquation);
|
||||
playButton.setHoverAnimationEquation(logoAnimationEquation);
|
||||
exitButton.setHoverAnimationEquation(logoAnimationEquation);
|
||||
final float logoHoverScale = 1.08f;
|
||||
logo.setHoverExpand(logoHoverScale);
|
||||
playButton.setHoverExpand(logoHoverScale);
|
||||
exitButton.setHoverExpand(logoHoverScale);
|
||||
|
||||
// initialize music buttons
|
||||
int musicWidth = GameImage.MUSIC_PLAY.getImage().getWidth();
|
||||
@@ -170,24 +187,40 @@ public class MainMenu extends BasicGameState {
|
||||
// initialize downloads button
|
||||
Image dlImg = GameImage.DOWNLOADS.getImage();
|
||||
downloadsButton = new MenuButton(dlImg, width - dlImg.getWidth() / 2f, height / 2f);
|
||||
downloadsButton.setHoverAnimationDuration(350);
|
||||
downloadsButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
downloadsButton.setHoverExpand(1.03f, Expand.LEFT);
|
||||
|
||||
// initialize repository button
|
||||
float startX = width * 0.997f, startY = height * 0.997f;
|
||||
if (Desktop.isDesktopSupported()) { // only if a webpage can be opened
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { // only if a webpage can be opened
|
||||
Image repoImg = GameImage.REPOSITORY.getImage();
|
||||
repoButton = new MenuButton(repoImg,
|
||||
startX - repoImg.getWidth(), startY - repoImg.getHeight()
|
||||
);
|
||||
repoButton.setHoverAnimationDuration(350);
|
||||
repoButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
repoButton.setHoverExpand();
|
||||
startX -= repoImg.getWidth() * 1.75f;
|
||||
} else
|
||||
startX -= width * 0.005f;
|
||||
}
|
||||
|
||||
// initialize update button
|
||||
Image bangImg = GameImage.BANG.getImage();
|
||||
updateButton = new MenuButton(bangImg, startX - bangImg.getWidth(), startY - bangImg.getHeight());
|
||||
updateButton.setHoverExpand(1.15f);
|
||||
// initialize update buttons
|
||||
float updateX = width / 2f, updateY = height * 17 / 18f;
|
||||
Image downloadImg = GameImage.DOWNLOAD.getImage();
|
||||
updateButton = new MenuButton(downloadImg, updateX, updateY);
|
||||
updateButton.setHoverAnimationDuration(400);
|
||||
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
|
||||
updateButton.setHoverExpand(1.1f);
|
||||
Image updateImg = GameImage.UPDATE.getImage();
|
||||
restartButton = new MenuButton(updateImg, updateX, updateY);
|
||||
restartButton.setHoverAnimationDuration(2000);
|
||||
restartButton.setHoverAnimationEquation(AnimationEquation.LINEAR);
|
||||
restartButton.setHoverRotate(360);
|
||||
|
||||
// logo animations
|
||||
float centerOffsetX = width / 5f;
|
||||
logoOpen = new AnimatedValue(400, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
||||
logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD);
|
||||
logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
reset();
|
||||
}
|
||||
@@ -201,27 +234,27 @@ public class MainMenu extends BasicGameState {
|
||||
// draw background
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
if (Options.isDynamicBackgroundEnabled() &&
|
||||
beatmap != null && beatmap.drawBG(width, height, bgAlpha, true))
|
||||
beatmap != null && beatmap.drawBackground(width, height, bgAlpha.getValue(), true))
|
||||
;
|
||||
else {
|
||||
Image bg = GameImage.MENU_BG.getImage();
|
||||
bg.setAlpha(bgAlpha);
|
||||
bg.setAlpha(bgAlpha.getValue());
|
||||
bg.draw();
|
||||
}
|
||||
|
||||
// top/bottom horizontal bars
|
||||
float oldAlpha = Utils.COLOR_BLACK_ALPHA.a;
|
||||
Utils.COLOR_BLACK_ALPHA.a = 0.2f;
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
float oldAlpha = Colors.BLACK_ALPHA.a;
|
||||
Colors.BLACK_ALPHA.a = 0.2f;
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height / 9f);
|
||||
g.fillRect(0, height * 8 / 9f, width, height / 9f);
|
||||
Utils.COLOR_BLACK_ALPHA.a = oldAlpha;
|
||||
Colors.BLACK_ALPHA.a = oldAlpha;
|
||||
|
||||
// draw downloads button
|
||||
downloadsButton.draw();
|
||||
|
||||
// draw buttons
|
||||
if (logoTimer > 0) {
|
||||
if (logoState == LogoState.OPEN || logoState == LogoState.CLOSING) {
|
||||
playButton.draw();
|
||||
exitButton.draw();
|
||||
}
|
||||
@@ -237,7 +270,7 @@ public class MainMenu extends BasicGameState {
|
||||
|
||||
// draw music position bar
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? BG_HOVER : BG_NORMAL);
|
||||
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL);
|
||||
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
|
||||
g.setColor(Color.white);
|
||||
if (!MusicController.isTrackLoading() && beatmap != null) {
|
||||
@@ -251,35 +284,26 @@ public class MainMenu extends BasicGameState {
|
||||
|
||||
// draw update button
|
||||
if (Updater.get().showButton()) {
|
||||
Color updateColor = null;
|
||||
switch (Updater.get().getStatus()) {
|
||||
case UPDATE_AVAILABLE:
|
||||
updateColor = Color.red;
|
||||
break;
|
||||
case UPDATE_DOWNLOADED:
|
||||
updateColor = Color.green;
|
||||
break;
|
||||
case UPDATE_DOWNLOADING:
|
||||
updateColor = Color.yellow;
|
||||
break;
|
||||
default:
|
||||
updateColor = Color.white;
|
||||
break;
|
||||
}
|
||||
updateButton.draw(updateColor);
|
||||
Updater.Status status = Updater.get().getStatus();
|
||||
if (status == Updater.Status.UPDATE_AVAILABLE || status == Updater.Status.UPDATE_DOWNLOADING)
|
||||
updateButton.draw();
|
||||
else if (status == Updater.Status.UPDATE_DOWNLOADED)
|
||||
restartButton.draw();
|
||||
}
|
||||
|
||||
// draw text
|
||||
float marginX = width * 0.015f, topMarginY = height * 0.01f, bottomMarginY = height * 0.015f;
|
||||
g.setFont(Utils.FONT_MEDIUM);
|
||||
float lineHeight = Utils.FONT_MEDIUM.getLineHeight() * 0.925f;
|
||||
g.setFont(Fonts.MEDIUM);
|
||||
float lineHeight = Fonts.MEDIUM.getLineHeight() * 0.925f;
|
||||
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
|
||||
BeatmapSetList.get().getMapSetCount(), BeatmapSetList.get().getMapCount()), marginX, topMarginY);
|
||||
if (MusicController.isTrackLoading())
|
||||
g.drawString("Track loading...", marginX, topMarginY + lineHeight);
|
||||
else if (MusicController.trackExists()) {
|
||||
if (Options.useUnicodeMetadata()) // load glyphs
|
||||
Utils.loadGlyphs(Utils.FONT_MEDIUM, beatmap.titleUnicode, beatmap.artistUnicode);
|
||||
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.titleUnicode);
|
||||
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.artistUnicode);
|
||||
}
|
||||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, topMarginY + lineHeight);
|
||||
g.drawString(String.format("%s: %s", beatmap.getArtist(), beatmap.getTitle()), marginX + 25, topMarginY + (lineHeight * 2));
|
||||
}
|
||||
@@ -305,7 +329,10 @@ public class MainMenu extends BasicGameState {
|
||||
exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
||||
if (repoButton != null)
|
||||
repoButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
updateButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
if (Updater.get().showButton()) {
|
||||
updateButton.autoHoverUpdate(delta, true);
|
||||
restartButton.autoHoverUpdate(delta, false);
|
||||
}
|
||||
downloadsButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
// ensure only one button is in hover state at once
|
||||
boolean noHoverUpdate = musicPositionBarContains(mouseX, mouseY);
|
||||
@@ -322,46 +349,46 @@ public class MainMenu extends BasicGameState {
|
||||
MusicController.toggleTrackDimmed(0.33f);
|
||||
|
||||
// fade in background
|
||||
if (bgAlpha < BG_MAX_ALPHA) {
|
||||
bgAlpha += delta / 1000f;
|
||||
if (bgAlpha > BG_MAX_ALPHA)
|
||||
bgAlpha = BG_MAX_ALPHA;
|
||||
}
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
if (!(Options.isDynamicBackgroundEnabled() && beatmap != null && beatmap.isBackgroundLoading()))
|
||||
bgAlpha.update(delta);
|
||||
|
||||
// buttons
|
||||
if (logoClicked) {
|
||||
if (logoTimer == 0) { // shifting to left
|
||||
if (logo.getX() > container.getWidth() / 3.3f)
|
||||
logo.setX(logo.getX() - delta);
|
||||
else
|
||||
logoTimer = 1;
|
||||
} else if (logoTimer >= MOVE_DELAY) // timer over: shift back to center
|
||||
logoClicked = false;
|
||||
else { // increment timer
|
||||
int centerX = container.getWidth() / 2;
|
||||
float currentLogoButtonAlpha;
|
||||
switch (logoState) {
|
||||
case DEFAULT:
|
||||
break;
|
||||
case OPENING:
|
||||
if (logoOpen.update(delta)) // shifting to left
|
||||
logo.setX(centerX - logoOpen.getValue());
|
||||
else {
|
||||
logoState = LogoState.OPEN;
|
||||
logoTimer = 0;
|
||||
logoButtonAlpha.setTime(0);
|
||||
}
|
||||
break;
|
||||
case OPEN:
|
||||
if (logoButtonAlpha.update(delta)) { // fade in buttons
|
||||
currentLogoButtonAlpha = logoButtonAlpha.getValue();
|
||||
playButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||
exitButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||
} else if (logoTimer >= LOGO_IDLE_DELAY) { // timer over: shift back to center
|
||||
logoState = LogoState.CLOSING;
|
||||
logoClose.setTime(0);
|
||||
logoTimer = 0;
|
||||
} else // increment timer
|
||||
logoTimer += delta;
|
||||
if (logoTimer <= 500) {
|
||||
// fade in buttons
|
||||
playButton.getImage().setAlpha(logoTimer / 400f);
|
||||
exitButton.getImage().setAlpha(logoTimer / 400f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// fade out buttons
|
||||
if (logoTimer > 0) {
|
||||
float alpha = playButton.getImage().getAlpha();
|
||||
if (alpha > 0f) {
|
||||
playButton.getImage().setAlpha(alpha - (delta / 200f));
|
||||
exitButton.getImage().setAlpha(alpha - (delta / 200f));
|
||||
} else
|
||||
logoTimer = 0;
|
||||
}
|
||||
|
||||
// move back to original location
|
||||
if (logo.getX() < container.getWidth() / 2) {
|
||||
logo.setX(logo.getX() + (delta / 3f));
|
||||
if (logo.getX() > container.getWidth() / 2)
|
||||
logo.setX(container.getWidth() / 2);
|
||||
break;
|
||||
case CLOSING:
|
||||
if (logoButtonAlpha.update(-delta)) { // fade out buttons
|
||||
currentLogoButtonAlpha = logoButtonAlpha.getValue();
|
||||
playButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||
exitButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||
}
|
||||
if (logoClose.update(delta)) // shifting to right
|
||||
logo.setX(centerX - logoClose.getValue());
|
||||
break;
|
||||
}
|
||||
|
||||
// tooltips
|
||||
@@ -373,8 +400,12 @@ public class MainMenu extends BasicGameState {
|
||||
UI.updateTooltip(delta, "Next track", false);
|
||||
else if (musicPrevious.contains(mouseX, mouseY))
|
||||
UI.updateTooltip(delta, "Previous track", false);
|
||||
else if (Updater.get().showButton() && updateButton.contains(mouseX, mouseY))
|
||||
UI.updateTooltip(delta, Updater.get().getStatus().getDescription(), true);
|
||||
else if (Updater.get().showButton()) {
|
||||
Updater.Status status = Updater.get().getStatus();
|
||||
if (((status == Updater.Status.UPDATE_AVAILABLE || status == Updater.Status.UPDATE_DOWNLOADING) && updateButton.contains(mouseX, mouseY)) ||
|
||||
(status == Updater.Status.UPDATE_DOWNLOADED && restartButton.contains(mouseX, mouseY)))
|
||||
UI.updateTooltip(delta, status.getDescription(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -412,8 +443,8 @@ public class MainMenu extends BasicGameState {
|
||||
musicPrevious.resetHover();
|
||||
if (repoButton != null && !repoButton.contains(mouseX, mouseY))
|
||||
repoButton.resetHover();
|
||||
if (!updateButton.contains(mouseX, mouseY))
|
||||
updateButton.resetHover();
|
||||
updateButton.resetHover();
|
||||
restartButton.resetHover();
|
||||
if (!downloadsButton.contains(mouseX, mouseY))
|
||||
downloadsButton.resetHover();
|
||||
}
|
||||
@@ -449,71 +480,85 @@ public class MainMenu extends BasicGameState {
|
||||
MusicController.resume();
|
||||
UI.sendBarNotification("Play");
|
||||
}
|
||||
return;
|
||||
} else if (musicNext.contains(x, y)) {
|
||||
nextTrack();
|
||||
UI.sendBarNotification(">> Next");
|
||||
return;
|
||||
} else if (musicPrevious.contains(x, y)) {
|
||||
if (!previous.isEmpty()) {
|
||||
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
|
||||
if (Options.isDynamicBackgroundEnabled())
|
||||
bgAlpha = 0f;
|
||||
bgAlpha.setTime(0);
|
||||
} else
|
||||
MusicController.setPosition(0);
|
||||
UI.sendBarNotification("<< Previous");
|
||||
return;
|
||||
}
|
||||
|
||||
// downloads button actions
|
||||
else if (downloadsButton.contains(x, y)) {
|
||||
if (downloadsButton.contains(x, y)) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
game.enterState(Opsu.STATE_DOWNLOADSMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
return;
|
||||
}
|
||||
|
||||
// repository button actions
|
||||
else if (repoButton != null && repoButton.contains(x, y)) {
|
||||
if (repoButton != null && repoButton.contains(x, y)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
UI.sendBarNotification("The repository web page could not be opened.");
|
||||
} catch (IOException e) {
|
||||
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// update button actions
|
||||
else if (Updater.get().showButton() && updateButton.contains(x, y)) {
|
||||
switch (Updater.get().getStatus()) {
|
||||
case UPDATE_AVAILABLE:
|
||||
if (Updater.get().showButton()) {
|
||||
Updater.Status status = Updater.get().getStatus();
|
||||
if (updateButton.contains(x, y) && status == Updater.Status.UPDATE_AVAILABLE) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
Updater.get().startDownload();
|
||||
break;
|
||||
case UPDATE_DOWNLOADED:
|
||||
updateButton.removeHoverEffects();
|
||||
updateButton.setHoverAnimationDuration(800);
|
||||
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
|
||||
updateButton.setHoverFade(0.6f);
|
||||
return;
|
||||
} else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
Updater.get().prepareUpdate();
|
||||
container.setForceExit(false);
|
||||
container.exit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// start moving logo (if clicked)
|
||||
else if (!logoClicked) {
|
||||
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
||||
if (logo.contains(x, y, 0.25f)) {
|
||||
logoClicked = true;
|
||||
logoState = LogoState.OPENING;
|
||||
logoOpen.setTime(0);
|
||||
logoTimer = 0;
|
||||
playButton.getImage().setAlpha(0f);
|
||||
exitButton.getImage().setAlpha(0f);
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// other button actions (if visible)
|
||||
else if (logoClicked) {
|
||||
else if (logoState == LogoState.OPEN || logoState == LogoState.OPENING) {
|
||||
if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
enterSongMenu();
|
||||
} else if (exitButton.contains(x, y, 0.25f))
|
||||
return;
|
||||
} else if (exitButton.contains(x, y, 0.25f)) {
|
||||
container.exit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,8 +577,9 @@ public class MainMenu extends BasicGameState {
|
||||
break;
|
||||
case Input.KEY_P:
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
if (!logoClicked) {
|
||||
logoClicked = true;
|
||||
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
||||
logoState = LogoState.OPENING;
|
||||
logoOpen.setTime(0);
|
||||
logoTimer = 0;
|
||||
playButton.getImage().setAlpha(0f);
|
||||
exitButton.getImage().setAlpha(0f);
|
||||
@@ -581,8 +627,11 @@ public class MainMenu extends BasicGameState {
|
||||
public void reset() {
|
||||
// reset logo
|
||||
logo.setX(container.getWidth() / 2);
|
||||
logoClicked = false;
|
||||
logoOpen.setTime(0);
|
||||
logoClose.setTime(0);
|
||||
logoButtonAlpha.setTime(0);
|
||||
logoTimer = 0;
|
||||
logoState = LogoState.DEFAULT;
|
||||
|
||||
logo.resetHover();
|
||||
playButton.resetHover();
|
||||
@@ -594,6 +643,7 @@ public class MainMenu extends BasicGameState {
|
||||
if (repoButton != null)
|
||||
repoButton.resetHover();
|
||||
updateButton.resetHover();
|
||||
restartButton.resetHover();
|
||||
downloadsButton.resetHover();
|
||||
}
|
||||
|
||||
@@ -611,7 +661,7 @@ public class MainMenu extends BasicGameState {
|
||||
previous.add(node.index);
|
||||
}
|
||||
if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
|
||||
bgAlpha = 0f;
|
||||
bgAlpha.setTime(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,8 @@ import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
|
||||
@@ -86,14 +88,18 @@ public class OptionsMenu extends BasicGameState {
|
||||
GameOption.DISABLE_MOUSE_WHEEL,
|
||||
GameOption.DISABLE_MOUSE_BUTTONS,
|
||||
GameOption.CURSOR_SIZE,
|
||||
GameOption.NEW_CURSOR
|
||||
GameOption.NEW_CURSOR,
|
||||
GameOption.DISABLE_CURSOR
|
||||
}),
|
||||
CUSTOM ("Custom", new GameOption[] {
|
||||
GameOption.FIXED_CS,
|
||||
GameOption.FIXED_HP,
|
||||
GameOption.FIXED_AR,
|
||||
GameOption.FIXED_OD,
|
||||
GameOption.CHECKPOINT
|
||||
GameOption.CHECKPOINT,
|
||||
GameOption.REPLAY_SEEKING,
|
||||
GameOption.DISABLE_UPDATER,
|
||||
GameOption.ENABLE_WATCH_SERVICE
|
||||
});
|
||||
|
||||
/** Total number of tabs. */
|
||||
@@ -110,10 +116,10 @@ public class OptionsMenu extends BasicGameState {
|
||||
private static OptionTab[] values = values();
|
||||
|
||||
/** Tab name. */
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/** Options array. */
|
||||
public GameOption[] options;
|
||||
public final GameOption[] options;
|
||||
|
||||
/** Associated tab button. */
|
||||
public MenuButton button;
|
||||
@@ -163,7 +169,7 @@ public class OptionsMenu extends BasicGameState {
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private Graphics g;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public OptionsMenu(int state) {
|
||||
this.state = state;
|
||||
@@ -182,8 +188,8 @@ public class OptionsMenu extends BasicGameState {
|
||||
|
||||
// option tabs
|
||||
Image tabImage = GameImage.MENU_TAB.getImage();
|
||||
float tabX = width * 0.032f + Utils.FONT_DEFAULT.getWidth("Change the way opsu! behaves") + (tabImage.getWidth() / 2);
|
||||
float tabY = Utils.FONT_XLARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() +
|
||||
float tabX = width * 0.032f + Fonts.DEFAULT.getWidth("Change the way opsu! behaves") + (tabImage.getWidth() / 2);
|
||||
float tabY = Fonts.XLARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
||||
height * 0.015f - (tabImage.getHeight() / 2f);
|
||||
int tabOffset = Math.min(tabImage.getWidth(), width / OptionTab.SIZE);
|
||||
for (OptionTab tab : OptionTab.values())
|
||||
@@ -198,22 +204,19 @@ public class OptionsMenu extends BasicGameState {
|
||||
@Override
|
||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
||||
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
||||
|
||||
// background
|
||||
GameImage.OPTIONS_BG.getImage().draw();
|
||||
|
||||
// title
|
||||
float marginX = width * 0.015f, marginY = height * 0.01f;
|
||||
Utils.FONT_XLARGE.drawString(marginX, marginY, "Options", Color.white);
|
||||
Utils.FONT_DEFAULT.drawString(marginX, marginY + Utils.FONT_XLARGE.getLineHeight() * 0.92f,
|
||||
Fonts.XLARGE.drawString(marginX, marginY, "Options", Color.white);
|
||||
Fonts.DEFAULT.drawString(marginX, marginY + Fonts.XLARGE.getLineHeight() * 0.92f,
|
||||
"Change the way opsu! behaves", Color.white);
|
||||
|
||||
// background
|
||||
GameImage.OPTIONS_BG.getImage().draw(0, lineY);
|
||||
|
||||
// game options
|
||||
g.setLineWidth(1f);
|
||||
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
||||
@@ -241,6 +244,7 @@ public class OptionsMenu extends BasicGameState {
|
||||
currentTab.getName(), true, false);
|
||||
g.setColor(Color.white);
|
||||
g.setLineWidth(2f);
|
||||
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
||||
g.drawLine(0, lineY, width, lineY);
|
||||
g.resetLineWidth();
|
||||
|
||||
@@ -248,15 +252,15 @@ public class OptionsMenu extends BasicGameState {
|
||||
|
||||
// key entry state
|
||||
if (keyEntryLeft || keyEntryRight) {
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height);
|
||||
g.setColor(Color.white);
|
||||
String prompt = (keyEntryLeft) ?
|
||||
"Please press the new left-click key." :
|
||||
"Please press the new right-click key.";
|
||||
Utils.FONT_LARGE.drawString(
|
||||
(width / 2) - (Utils.FONT_LARGE.getWidth(prompt) / 2),
|
||||
(height / 2) - Utils.FONT_LARGE.getLineHeight(), prompt
|
||||
Fonts.LARGE.drawString(
|
||||
(width / 2) - (Fonts.LARGE.getWidth(prompt) / 2),
|
||||
(height / 2) - Fonts.LARGE.getLineHeight(), prompt
|
||||
);
|
||||
}
|
||||
|
||||
@@ -413,14 +417,14 @@ public class OptionsMenu extends BasicGameState {
|
||||
*/
|
||||
private void drawOption(GameOption option, int pos, boolean focus) {
|
||||
int width = container.getWidth();
|
||||
int textHeight = Utils.FONT_LARGE.getLineHeight();
|
||||
int textHeight = Fonts.LARGE.getLineHeight();
|
||||
float y = textY + (pos * offsetY);
|
||||
Color color = (focus) ? Color.cyan : Color.white;
|
||||
|
||||
Utils.FONT_LARGE.drawString(width / 30, y, option.getName(), color);
|
||||
Utils.FONT_LARGE.drawString(width / 2, y, option.getValueString(), color);
|
||||
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
||||
g.setColor(Utils.COLOR_WHITE_ALPHA);
|
||||
Fonts.LARGE.drawString(width / 30, y, option.getName(), color);
|
||||
Fonts.LARGE.drawString(width / 2, y, option.getValueString(), color);
|
||||
Fonts.SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
||||
g.setColor(Colors.WHITE_ALPHA);
|
||||
g.drawLine(0, y + textHeight, width, y + textHeight);
|
||||
}
|
||||
|
||||
@@ -433,7 +437,7 @@ public class OptionsMenu extends BasicGameState {
|
||||
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
||||
return null;
|
||||
|
||||
int index = (y - textY + Utils.FONT_LARGE.getLineHeight()) / offsetY;
|
||||
int index = (y - textY + Fonts.LARGE.getLineHeight()) / offsetY;
|
||||
if (index >= currentTab.options.length)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.GameMod;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.OszUnpacker;
|
||||
import itdelatrisu.opsu.ScoreData;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MultiClip;
|
||||
@@ -32,18 +31,32 @@ import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapDifficultyCalculator;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSet;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSortOrder;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapWatchService;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapWatchService.BeatmapWatchServiceListener;
|
||||
import itdelatrisu.opsu.beatmap.LRUCache;
|
||||
import itdelatrisu.opsu.beatmap.OszUnpacker;
|
||||
import itdelatrisu.opsu.db.BeatmapDB;
|
||||
import itdelatrisu.opsu.db.ScoreDB;
|
||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||
import itdelatrisu.opsu.ui.KinecticScrolling;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.MenuButton;
|
||||
import itdelatrisu.opsu.ui.StarStream;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardWatchEventKinds;
|
||||
import java.nio.file.WatchEvent.Kind;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -145,8 +158,8 @@ public class SongMenu extends BasicGameState {
|
||||
/** Button coordinate values. */
|
||||
private float buttonX, buttonY, buttonOffset, buttonWidth, buttonHeight;
|
||||
|
||||
/** Current x offset of song buttons for mouse hover, in pixels. */
|
||||
private float hoverOffset = 0f;
|
||||
/** Horizontal offset of song buttons for mouse hover, in pixels. */
|
||||
private AnimatedValue hoverOffset = new AnimatedValue(250, 0, MAX_HOVER_OFFSET, AnimationEquation.OUT_QUART);
|
||||
|
||||
/** Current index of hovered song button. */
|
||||
private BeatmapSetNode hoverIndex = null;
|
||||
@@ -209,11 +222,52 @@ public class SongMenu extends BasicGameState {
|
||||
/** The text length of the last string in the search TextField. */
|
||||
private int lastSearchTextLength = -1;
|
||||
|
||||
/** Whether the song folder changed (notified via the watch service). */
|
||||
private boolean songFolderChanged = false;
|
||||
|
||||
/** The last background image. */
|
||||
private File lastBackgroundImage;
|
||||
|
||||
/** Background alpha level (for fade-in effect). */
|
||||
private AnimatedValue bgAlpha = new AnimatedValue(800, 0f, 1f, AnimationEquation.OUT_QUAD);
|
||||
|
||||
/** Timer for animations when a new song node is selected. */
|
||||
private AnimatedValue songChangeTimer = new AnimatedValue(900, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
/** Timer for the music icon animation when a new song node is selected. */
|
||||
private AnimatedValue musicIconBounceTimer = new AnimatedValue(350, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
/**
|
||||
* Beatmaps whose difficulties were recently computed (if flag is non-null).
|
||||
* Unless the Boolean flag is null, then upon removal, the beatmap's objects will
|
||||
* be cleared (to be garbage collected). If the flag is true, also clear the
|
||||
* beatmap's array fields (timing points, etc.).
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private LRUCache<Beatmap, Boolean> beatmapsCalculated = new LRUCache<Beatmap, Boolean>(12) {
|
||||
@Override
|
||||
public void eldestRemoved(Map.Entry<Beatmap, Boolean> eldest) {
|
||||
Boolean b = eldest.getValue();
|
||||
if (b != null) {
|
||||
Beatmap beatmap = eldest.getKey();
|
||||
beatmap.objects = null;
|
||||
if (b) {
|
||||
beatmap.timingPoints = null;
|
||||
beatmap.breaks = null;
|
||||
beatmap.combo = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** The star stream. */
|
||||
private StarStream starStream;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
private Input input;
|
||||
private int state;
|
||||
private final int state;
|
||||
|
||||
public SongMenu(int state) {
|
||||
this.state = state;
|
||||
@@ -231,8 +285,8 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// header/footer coordinates
|
||||
headerY = height * 0.0075f + GameImage.MENU_MUSICNOTE.getImage().getHeight() +
|
||||
Utils.FONT_BOLD.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() +
|
||||
Utils.FONT_SMALL.getLineHeight();
|
||||
Fonts.BOLD.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
||||
Fonts.SMALL.getLineHeight();
|
||||
footerY = height - GameImage.SELECTION_MODS.getImage().getHeight();
|
||||
|
||||
// initialize sorts
|
||||
@@ -253,11 +307,11 @@ public class SongMenu extends BasicGameState {
|
||||
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
||||
|
||||
// search
|
||||
int textFieldX = (int) (width * 0.7125f + Utils.FONT_BOLD.getWidth("Search: "));
|
||||
int textFieldY = (int) (headerY + Utils.FONT_BOLD.getLineHeight() / 2);
|
||||
int textFieldX = (int) (width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
||||
int textFieldY = (int) (headerY + Fonts.BOLD.getLineHeight() / 2);
|
||||
search = new TextField(
|
||||
container, Utils.FONT_BOLD, textFieldX, textFieldY,
|
||||
(int) (width * 0.99f) - textFieldX, Utils.FONT_BOLD.getLineHeight()
|
||||
container, Fonts.BOLD, textFieldX, textFieldY,
|
||||
(int) (width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()
|
||||
);
|
||||
search.setBackgroundColor(Color.transparent);
|
||||
search.setBorderColor(Color.transparent);
|
||||
@@ -287,6 +341,22 @@ public class SongMenu extends BasicGameState {
|
||||
int loaderDim = GameImage.MENU_MUSICNOTE.getImage().getWidth();
|
||||
SpriteSheet spr = new SpriteSheet(GameImage.MENU_LOADER.getImage(), loaderDim, loaderDim);
|
||||
loader = new Animation(spr, 50);
|
||||
|
||||
// beatmap watch service listener
|
||||
final StateBasedGame game_ = game;
|
||||
BeatmapWatchService.addListener(new BeatmapWatchServiceListener() {
|
||||
@Override
|
||||
public void eventReceived(Kind<?> kind, Path child) {
|
||||
if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
|
||||
songFolderChanged = true;
|
||||
if (game_.getCurrentStateID() == Opsu.STATE_SONGMENU)
|
||||
UI.sendBarNotification("Changes in Songs folder detected. Hit F5 to refresh.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// star stream
|
||||
starStream = new StarStream(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,23 +370,30 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// background
|
||||
if (focusNode != null) {
|
||||
Beatmap focusNodeBeatmap = focusNode.getBeatmapSet().get(focusNode.beatmapIndex);
|
||||
if (!focusNodeBeatmap.drawBG(width, height, 1.0f, true))
|
||||
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
|
||||
if (!focusNodeBeatmap.drawBackground(width, height, bgAlpha.getValue(), true))
|
||||
GameImage.PLAYFIELD.getImage().draw();
|
||||
}
|
||||
|
||||
// star stream
|
||||
starStream.draw();
|
||||
|
||||
// song buttons
|
||||
BeatmapSetNode node = startNode;
|
||||
int startNodeOffsetoffset = 0;
|
||||
if (node.prev != null) {
|
||||
startNodeOffsetoffset = -1;
|
||||
node = node.prev;
|
||||
}
|
||||
g.setClip(0, (int) (headerY + DIVIDER_LINE_WIDTH / 2), width, (int) (footerY - headerY));
|
||||
for (int i = startNodeOffset; i < MAX_SONG_BUTTONS + 1 && node != null; i++, node = node.next) {
|
||||
for (int i = startNodeOffset + startNodeOffsetoffset; i < MAX_SONG_BUTTONS + 1 && node != null; i++, node = node.next) {
|
||||
// draw the node
|
||||
float offset = (node == hoverIndex) ? hoverOffset : 0f;
|
||||
float offset = (node == hoverIndex) ? hoverOffset.getValue() : 0f;
|
||||
float ypos = buttonY + (i*buttonOffset) ;
|
||||
float mid = height/2 - ypos - buttonOffset/2;
|
||||
final float circleRadi = 1000 * GameImage.getUIscale();
|
||||
//finds points along a very large circle
|
||||
// x^2 = h^2 - y^2
|
||||
float t = circleRadi*circleRadi - (mid*mid);
|
||||
final float circleRadi = 700 * GameImage.getUIscale();
|
||||
//finds points along a very large circle (x^2 = h^2 - y^2)
|
||||
float t = circleRadi * circleRadi - (mid * mid);
|
||||
float xpos = (float)(t>0?Math.sqrt(t):0) - circleRadi + 50 * GameImage.getUIscale();
|
||||
ScoreData[] scores = getScoreDataForNode(node, false);
|
||||
node.draw(buttonX - offset - xpos, ypos,
|
||||
@@ -336,7 +413,7 @@ public class SongMenu extends BasicGameState {
|
||||
MAX_SONG_BUTTONS * buttonOffset,
|
||||
width, headerY + DIVIDER_LINE_WIDTH / 2,
|
||||
0, MAX_SONG_BUTTONS * buttonOffset,
|
||||
Utils.COLOR_BLACK_ALPHA, Color.white, true);
|
||||
Colors.BLACK_ALPHA, Color.white, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,14 +422,19 @@ public class SongMenu extends BasicGameState {
|
||||
ScoreData.clipToDownloadArea(g);
|
||||
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
||||
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
||||
for (int i = 0; i < MAX_SCORE_BUTTONS + 1; i++) {
|
||||
int rank = startScore + i;
|
||||
|
||||
int scoreButtons = Math.min(focusScores.length - startScore, MAX_SCORE_BUTTONS + 1);
|
||||
float timerScale = 1f - (1 / 3f) * ((MAX_SCORE_BUTTONS - scoreButtons) / (float) (MAX_SCORE_BUTTONS - 1));
|
||||
int duration = (int) (songChangeTimer.getDuration() * timerScale);
|
||||
int segmentDuration = (int) ((2 / 3f) * songChangeTimer.getDuration());
|
||||
int time = songChangeTimer.getTime();
|
||||
for (int i = 0, rank = startScore; i < scoreButtons; i++, rank++) {
|
||||
if (rank < 0)
|
||||
continue;
|
||||
if (rank >= focusScores.length)
|
||||
break;
|
||||
long prevScore = (rank + 1 < focusScores.length) ? focusScores[rank + 1].score : -1;
|
||||
focusScores[rank].draw(g, offset + i*ScoreData.getButtonOffset(), rank, prevScore, ScoreData.buttonContains(mouseX, mouseY-offset, i));
|
||||
float t = Utils.clamp((time - (i * (duration - segmentDuration) / scoreButtons)) / (float) segmentDuration, 0f, 1f);
|
||||
boolean focus = (t >= 0.9999f && ScoreData.buttonContains(mouseX, mouseY - offset, i));
|
||||
focusScores[rank].draw(g, offset + i*ScoreData.getButtonOffset(), rank, prevScore, focus, t);
|
||||
}
|
||||
g.clearClip();
|
||||
|
||||
@@ -360,13 +442,12 @@ public class SongMenu extends BasicGameState {
|
||||
if (focusScores.length > MAX_SCORE_BUTTONS && ScoreData.areaContains(mouseX, mouseY))
|
||||
ScoreData.drawScrollbar(g, startScorePos.getPosition() , focusScores.length * ScoreData.getButtonOffset());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// top/bottom bars
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, headerY);
|
||||
g.fillRect(0, footerY, width, height - footerY);
|
||||
g.setColor(Utils.COLOR_BLUE_DIVIDER);
|
||||
g.setColor(Colors.BLUE_DIVIDER);
|
||||
g.setLineWidth(DIVIDER_LINE_WIDTH);
|
||||
g.drawLine(0, headerY, width, headerY);
|
||||
g.drawLine(0, footerY, width, footerY);
|
||||
@@ -379,8 +460,13 @@ public class SongMenu extends BasicGameState {
|
||||
Image musicNote = GameImage.MENU_MUSICNOTE.getImage();
|
||||
if (MusicController.isTrackLoading())
|
||||
loader.draw(marginX, marginY);
|
||||
else
|
||||
musicNote.draw(marginX, marginY);
|
||||
else {
|
||||
float t = musicIconBounceTimer.getValue() * 2f;
|
||||
if (t > 1)
|
||||
t = 2f - t;
|
||||
float musicNoteScale = 1f + 0.3f * t;
|
||||
musicNote.getScaledCopy(musicNoteScale).drawCentered(marginX + musicNote.getWidth() / 2f, marginY + musicNote.getHeight() / 2f);
|
||||
}
|
||||
int iconWidth = musicNote.getWidth();
|
||||
|
||||
// song info text
|
||||
@@ -388,26 +474,49 @@ public class SongMenu extends BasicGameState {
|
||||
songInfo = focusNode.getInfo();
|
||||
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||
Beatmap beatmap = focusNode.getBeatmapSet().get(0);
|
||||
Utils.loadGlyphs(Utils.FONT_LARGE, beatmap.titleUnicode, beatmap.artistUnicode);
|
||||
Fonts.loadGlyphs(Fonts.LARGE, beatmap.titleUnicode);
|
||||
Fonts.loadGlyphs(Fonts.LARGE, beatmap.artistUnicode);
|
||||
}
|
||||
}
|
||||
marginX += 5;
|
||||
Color c = Colors.WHITE_FADE;
|
||||
float oldAlpha = c.a;
|
||||
float t = AnimationEquation.OUT_QUAD.calc(songChangeTimer.getValue());
|
||||
float headerTextY = marginY * 0.2f;
|
||||
Utils.FONT_LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], Color.white);
|
||||
headerTextY += Utils.FONT_LARGE.getLineHeight() - 6;
|
||||
Utils.FONT_DEFAULT.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[1], Color.white);
|
||||
headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 2;
|
||||
float speedModifier = GameMod.getSpeedMultiplier();
|
||||
Color color2 = (speedModifier == 1f) ? Color.white :
|
||||
(speedModifier > 1f) ? Utils.COLOR_RED_HIGHLIGHT : Utils.COLOR_BLUE_HIGHLIGHT;
|
||||
Utils.FONT_BOLD.drawString(marginX, headerTextY, songInfo[2], color2);
|
||||
headerTextY += Utils.FONT_BOLD.getLineHeight() - 4;
|
||||
Utils.FONT_DEFAULT.drawString(marginX, headerTextY, songInfo[3], Color.white);
|
||||
headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 4;
|
||||
float multiplier = GameMod.getDifficultyMultiplier();
|
||||
Color color4 = (multiplier == 1f) ? Color.white :
|
||||
(multiplier > 1f) ? Utils.COLOR_RED_HIGHLIGHT : Utils.COLOR_BLUE_HIGHLIGHT;
|
||||
Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], color4);
|
||||
c.a = Math.min(t * songInfo.length / 1.5f, 1f);
|
||||
if (c.a > 0)
|
||||
Fonts.LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], c);
|
||||
headerTextY += Fonts.LARGE.getLineHeight() - 6;
|
||||
c.a = Math.min((t - 1f / (songInfo.length * 1.5f)) * songInfo.length / 1.5f, 1f);
|
||||
if (c.a > 0)
|
||||
Fonts.DEFAULT.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[1], c);
|
||||
headerTextY += Fonts.DEFAULT.getLineHeight() - 2;
|
||||
c.a = Math.min((t - 2f / (songInfo.length * 1.5f)) * songInfo.length / 1.5f, 1f);
|
||||
if (c.a > 0) {
|
||||
float speedModifier = GameMod.getSpeedMultiplier();
|
||||
Color color2 = (speedModifier == 1f) ? c :
|
||||
(speedModifier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
||||
float oldAlpha2 = color2.a;
|
||||
color2.a = c.a;
|
||||
Fonts.BOLD.drawString(marginX, headerTextY, songInfo[2], color2);
|
||||
color2.a = oldAlpha2;
|
||||
}
|
||||
headerTextY += Fonts.BOLD.getLineHeight() - 4;
|
||||
c.a = Math.min((t - 3f / (songInfo.length * 1.5f)) * songInfo.length / 1.5f, 1f);
|
||||
if (c.a > 0)
|
||||
Fonts.DEFAULT.drawString(marginX, headerTextY, songInfo[3], c);
|
||||
headerTextY += Fonts.DEFAULT.getLineHeight() - 4;
|
||||
c.a = Math.min((t - 4f / (songInfo.length * 1.5f)) * songInfo.length / 1.5f, 1f);
|
||||
if (c.a > 0) {
|
||||
float multiplier = GameMod.getDifficultyMultiplier();
|
||||
Color color4 = (multiplier == 1f) ? c :
|
||||
(multiplier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
||||
float oldAlpha4 = color4.a;
|
||||
color4.a = c.a;
|
||||
Fonts.SMALL.drawString(marginX, headerTextY, songInfo[4], color4);
|
||||
color4.a = oldAlpha4;
|
||||
}
|
||||
c.a = oldAlpha;
|
||||
}
|
||||
|
||||
// selection buttons
|
||||
@@ -440,38 +549,41 @@ public class SongMenu extends BasicGameState {
|
||||
int searchX = search.getX(), searchY = search.getY();
|
||||
float searchBaseX = width * 0.7f;
|
||||
float searchTextX = width * 0.7125f;
|
||||
float searchRectHeight = Utils.FONT_BOLD.getLineHeight() * 2;
|
||||
float searchExtraHeight = Utils.FONT_DEFAULT.getLineHeight() * 0.7f;
|
||||
float searchRectHeight = Fonts.BOLD.getLineHeight() * 2;
|
||||
float searchExtraHeight = Fonts.DEFAULT.getLineHeight() * 0.7f;
|
||||
float searchProgress = (searchTransitionTimer < SEARCH_TRANSITION_TIME) ?
|
||||
((float) searchTransitionTimer / SEARCH_TRANSITION_TIME) : 1f;
|
||||
float oldAlpha = Utils.COLOR_BLACK_ALPHA.a;
|
||||
float oldAlpha = Colors.BLACK_ALPHA.a;
|
||||
if (searchEmpty) {
|
||||
searchRectHeight += (1f - searchProgress) * searchExtraHeight;
|
||||
Utils.COLOR_BLACK_ALPHA.a = 0.5f - searchProgress * 0.3f;
|
||||
Colors.BLACK_ALPHA.a = 0.5f - searchProgress * 0.3f;
|
||||
} else {
|
||||
searchRectHeight += searchProgress * searchExtraHeight;
|
||||
Utils.COLOR_BLACK_ALPHA.a = 0.2f + searchProgress * 0.3f;
|
||||
Colors.BLACK_ALPHA.a = 0.2f + searchProgress * 0.3f;
|
||||
}
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(searchBaseX, headerY + DIVIDER_LINE_WIDTH / 2, width - searchBaseX, searchRectHeight);
|
||||
Utils.COLOR_BLACK_ALPHA.a = oldAlpha;
|
||||
Utils.FONT_BOLD.drawString(searchTextX, searchY, "Search:", Utils.COLOR_GREEN_SEARCH);
|
||||
Colors.BLACK_ALPHA.a = oldAlpha;
|
||||
Fonts.BOLD.drawString(searchTextX, searchY, "Search:", Colors.GREEN_SEARCH);
|
||||
if (searchEmpty)
|
||||
Utils.FONT_BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
||||
Fonts.BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
||||
else {
|
||||
g.setColor(Color.white);
|
||||
// TODO: why is this needed to correctly position the TextField?
|
||||
search.setLocation(searchX - 3, searchY - 1);
|
||||
search.render(container, g);
|
||||
search.setLocation(searchX, searchY);
|
||||
Utils.FONT_DEFAULT.drawString(searchTextX, searchY + Utils.FONT_BOLD.getLineHeight(),
|
||||
Fonts.DEFAULT.drawString(searchTextX, searchY + Fonts.BOLD.getLineHeight(),
|
||||
(searchResultString == null) ? "Searching..." : searchResultString, Color.white);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// reloading beatmaps
|
||||
if (reloadThread != null) {
|
||||
// darken the screen
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
UI.drawLoadingProgress(g);
|
||||
@@ -510,6 +622,21 @@ public class SongMenu extends BasicGameState {
|
||||
}
|
||||
}
|
||||
|
||||
if (focusNode != null) {
|
||||
// fade in background
|
||||
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
|
||||
if (!focusNodeBeatmap.isBackgroundLoading())
|
||||
bgAlpha.update(delta);
|
||||
|
||||
// song change timers
|
||||
songChangeTimer.update(delta);
|
||||
if (!MusicController.isTrackLoading())
|
||||
musicIconBounceTimer.update(delta);
|
||||
}
|
||||
|
||||
// star stream
|
||||
starStream.update(delta);
|
||||
|
||||
// search
|
||||
search.setFocus(true);
|
||||
searchTimer += delta;
|
||||
@@ -574,14 +701,10 @@ public class SongMenu extends BasicGameState {
|
||||
if ((mouseX > cx && mouseX < cx + buttonWidth) &&
|
||||
(mouseY > buttonY + (i * buttonOffset) && mouseY < buttonY + (i * buttonOffset) + buttonHeight)) {
|
||||
if (node == hoverIndex) {
|
||||
if (hoverOffset < MAX_HOVER_OFFSET) {
|
||||
hoverOffset += delta / 3f;
|
||||
if (hoverOffset > MAX_HOVER_OFFSET)
|
||||
hoverOffset = MAX_HOVER_OFFSET;
|
||||
}
|
||||
hoverOffset.update(delta);
|
||||
} else {
|
||||
hoverIndex = node ;
|
||||
hoverOffset = 0f;
|
||||
hoverOffset.setTime(0);
|
||||
}
|
||||
isHover = true;
|
||||
break;
|
||||
@@ -589,21 +712,19 @@ public class SongMenu extends BasicGameState {
|
||||
}
|
||||
}
|
||||
if (!isHover) {
|
||||
hoverOffset = 0f;
|
||||
hoverOffset.setTime(0);
|
||||
hoverIndex = null;
|
||||
} else
|
||||
return;
|
||||
|
||||
// tooltips
|
||||
if (focusScores != null) {
|
||||
if (focusScores != null && ScoreData.areaContains(mouseX, mouseY)) {
|
||||
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
||||
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
||||
for (int i = 0; i < MAX_SCORE_BUTTONS; i++) {
|
||||
int rank = startScore + i;
|
||||
int scoreButtons = Math.min(focusScores.length - startScore, MAX_SCORE_BUTTONS);
|
||||
for (int i = 0, rank = startScore; i < scoreButtons; i++, rank++) {
|
||||
if (rank < 0)
|
||||
continue;
|
||||
if (rank >= focusScores.length)
|
||||
break;
|
||||
if (ScoreData.buttonContains(mouseX, mouseY - offset, i)) {
|
||||
UI.updateTooltip(delta, focusScores[rank].getTooltipString(), true);
|
||||
break;
|
||||
@@ -689,7 +810,7 @@ public class SongMenu extends BasicGameState {
|
||||
float cx = (node.index == expandedIndex) ? buttonX * 0.9f : buttonX;
|
||||
if ((x > cx && x < cx + buttonWidth) &&
|
||||
(y > buttonY + (i * buttonOffset) && y < buttonY + (i * buttonOffset) + buttonHeight)) {
|
||||
float oldHoverOffset = hoverOffset;
|
||||
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||
BeatmapSetNode oldHoverIndex = hoverIndex;
|
||||
|
||||
// clicked node is already expanded
|
||||
@@ -714,7 +835,7 @@ public class SongMenu extends BasicGameState {
|
||||
}
|
||||
|
||||
// restore hover data
|
||||
hoverOffset = oldHoverOffset;
|
||||
hoverOffset.setTime(oldHoverOffsetTime);
|
||||
hoverIndex = oldHoverIndex;
|
||||
|
||||
// open beatmap menu
|
||||
@@ -728,12 +849,10 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// score buttons
|
||||
if (focusScores != null && ScoreData.areaContains(x, y)) {
|
||||
for (int i = 0; i < MAX_SCORE_BUTTONS + 1; i++) {
|
||||
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
||||
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
||||
int rank = startScore + i;
|
||||
if (rank >= focusScores.length)
|
||||
break;
|
||||
int startScore = (int) (startScorePos.getPosition() / ScoreData.getButtonOffset());
|
||||
int offset = (int) (-startScorePos.getPosition() + startScore * ScoreData.getButtonOffset());
|
||||
int scoreButtons = Math.min(focusScores.length - startScore, MAX_SCORE_BUTTONS);
|
||||
for (int i = 0, rank = startScore; i < scoreButtons; i++, rank++) {
|
||||
if (ScoreData.buttonContains(x, y - offset, i)) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
if (button != Input.MOUSE_RIGHT_BUTTON) {
|
||||
@@ -805,8 +924,12 @@ public class SongMenu extends BasicGameState {
|
||||
break;
|
||||
case Input.KEY_F5:
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.RELOAD);
|
||||
game.enterState(Opsu.STATE_BUTTONMENU);
|
||||
if (songFolderChanged)
|
||||
reloadBeatmaps(false);
|
||||
else {
|
||||
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.RELOAD);
|
||||
game.enterState(Opsu.STATE_BUTTONMENU);
|
||||
}
|
||||
break;
|
||||
case Input.KEY_DELETE:
|
||||
if (focusNode == null)
|
||||
@@ -851,11 +974,11 @@ public class SongMenu extends BasicGameState {
|
||||
if (next != null) {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
BeatmapSetNode oldStartNode = startNode;
|
||||
float oldHoverOffset = hoverOffset;
|
||||
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||
BeatmapSetNode oldHoverIndex = hoverIndex;
|
||||
setFocus(next, 0, false, true);
|
||||
if (startNode == oldStartNode) {
|
||||
hoverOffset = oldHoverOffset;
|
||||
hoverOffset.setTime(oldHoverOffsetTime);
|
||||
hoverIndex = oldHoverIndex;
|
||||
}
|
||||
}
|
||||
@@ -867,11 +990,11 @@ public class SongMenu extends BasicGameState {
|
||||
if (prev != null) {
|
||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||
BeatmapSetNode oldStartNode = startNode;
|
||||
float oldHoverOffset = hoverOffset;
|
||||
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||
BeatmapSetNode oldHoverIndex = hoverIndex;
|
||||
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.getBeatmapSet().size() - 1, false, true);
|
||||
if (startNode == oldStartNode) {
|
||||
hoverOffset = oldHoverOffset;
|
||||
hoverOffset.setTime(oldHoverOffsetTime);
|
||||
hoverIndex = oldHoverIndex;
|
||||
}
|
||||
}
|
||||
@@ -965,18 +1088,26 @@ public class SongMenu extends BasicGameState {
|
||||
selectRandomButton.resetHover();
|
||||
selectMapOptionsButton.resetHover();
|
||||
selectOptionsButton.resetHover();
|
||||
hoverOffset = 0f;
|
||||
hoverOffset.setTime(0);
|
||||
hoverIndex = null;
|
||||
startScorePos.setPosition(0);
|
||||
beatmapMenuTimer = -1;
|
||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||
songInfo = null;
|
||||
bgAlpha.setTime(bgAlpha.getDuration());
|
||||
songChangeTimer.setTime(songChangeTimer.getDuration());
|
||||
musicIconBounceTimer.setTime(musicIconBounceTimer.getDuration());
|
||||
starStream.clear();
|
||||
|
||||
// reset song stack
|
||||
randomStack = new Stack<SongNode>();
|
||||
|
||||
// reload beatmaps if song folder changed
|
||||
if (songFolderChanged && stateAction != MenuState.RELOAD)
|
||||
reloadBeatmaps(false);
|
||||
|
||||
// set focus node if not set (e.g. theme song playing)
|
||||
if (focusNode == null && BeatmapSetList.get().size() > 0)
|
||||
else if (focusNode == null && BeatmapSetList.get().size() > 0)
|
||||
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
|
||||
// reset music track
|
||||
@@ -1003,13 +1134,13 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// destroy skin images, if any
|
||||
for (GameImage img : GameImage.values()) {
|
||||
if (img.isSkinnable())
|
||||
img.destroySkinImage();
|
||||
if (img.isBeatmapSkinnable())
|
||||
img.destroyBeatmapSkinImage();
|
||||
}
|
||||
|
||||
// reload scores
|
||||
if (focusNode != null) {
|
||||
scoreMap = ScoreDB.getMapSetScores(focusNode.getBeatmapSet().get(focusNode.beatmapIndex));
|
||||
scoreMap = ScoreDB.getMapSetScores(focusNode.getSelectedBeatmap());
|
||||
focusScores = getScoreDataForNode(focusNode, true);
|
||||
}
|
||||
|
||||
@@ -1022,7 +1153,7 @@ public class SongMenu extends BasicGameState {
|
||||
case BEATMAP: // clear all scores
|
||||
if (stateActionNode == null || stateActionNode.beatmapIndex == -1)
|
||||
break;
|
||||
Beatmap beatmap = stateActionNode.getBeatmapSet().get(stateActionNode.beatmapIndex);
|
||||
Beatmap beatmap = stateActionNode.getSelectedBeatmap();
|
||||
ScoreDB.deleteScore(beatmap);
|
||||
if (stateActionNode == focusNode) {
|
||||
focusScores = null;
|
||||
@@ -1033,7 +1164,7 @@ public class SongMenu extends BasicGameState {
|
||||
if (stateActionScore == null)
|
||||
break;
|
||||
ScoreDB.deleteScore(stateActionScore);
|
||||
scoreMap = ScoreDB.getMapSetScores(focusNode.getBeatmapSet().get(focusNode.beatmapIndex));
|
||||
scoreMap = ScoreDB.getMapSetScores(focusNode.getSelectedBeatmap());
|
||||
focusScores = getScoreDataForNode(focusNode, true);
|
||||
startScorePos.setPosition(0);
|
||||
break;
|
||||
@@ -1095,44 +1226,7 @@ public class SongMenu extends BasicGameState {
|
||||
}
|
||||
break;
|
||||
case RELOAD: // reload beatmaps
|
||||
// reset state and node references
|
||||
MusicController.reset();
|
||||
startNode = focusNode = null;
|
||||
scoreMap = null;
|
||||
focusScores = null;
|
||||
oldFocusNode = null;
|
||||
randomStack = new Stack<SongNode>();
|
||||
songInfo = null;
|
||||
hoverOffset = 0f;
|
||||
hoverIndex = null;
|
||||
search.setText("");
|
||||
searchTimer = SEARCH_DELAY;
|
||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||
searchResultString = null;
|
||||
|
||||
// reload songs in new thread
|
||||
reloadThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
// clear the beatmap cache
|
||||
BeatmapDB.clearDatabase();
|
||||
|
||||
// invoke unpacker and parser
|
||||
File beatmapDir = Options.getBeatmapDir();
|
||||
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
|
||||
BeatmapParser.parseAllFiles(beatmapDir);
|
||||
|
||||
// initialize song list
|
||||
if (BeatmapSetList.get().size() > 0) {
|
||||
BeatmapSetList.get().init();
|
||||
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
} else
|
||||
MusicController.playThemeSong();
|
||||
|
||||
reloadThread = null;
|
||||
}
|
||||
};
|
||||
reloadThread.start();
|
||||
reloadBeatmaps(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1210,15 +1304,25 @@ public class SongMenu extends BasicGameState {
|
||||
if (node == null)
|
||||
return null;
|
||||
|
||||
hoverOffset = 0f;
|
||||
hoverOffset.setTime(0);
|
||||
hoverIndex = null;
|
||||
songInfo = null;
|
||||
songChangeTimer.setTime(0);
|
||||
musicIconBounceTimer.setTime(0);
|
||||
BeatmapSetNode oldFocus = focusNode;
|
||||
|
||||
// expand node before focusing it
|
||||
int expandedIndex = BeatmapSetList.get().getExpandedIndex();
|
||||
if (node.index != expandedIndex) {
|
||||
node = BeatmapSetList.get().expand(node.index);
|
||||
|
||||
|
||||
// calculate difficulties
|
||||
calculateStarRatings(node.getBeatmapSet());
|
||||
|
||||
// if start node was previously expanded, move it
|
||||
if (startNode != null && startNode.index == expandedIndex)
|
||||
startNode = BeatmapSetList.get().getBaseNode(startNode.index);
|
||||
}
|
||||
|
||||
// check beatmapIndex bounds
|
||||
@@ -1227,7 +1331,7 @@ public class SongMenu extends BasicGameState {
|
||||
beatmapIndex = (int) (Math.random() * length);
|
||||
|
||||
focusNode = BeatmapSetList.get().getNode(node, beatmapIndex);
|
||||
Beatmap beatmap = focusNode.getBeatmapSet().get(focusNode.beatmapIndex);
|
||||
Beatmap beatmap = focusNode.getSelectedBeatmap();
|
||||
MusicController.play(beatmap, false, preview);
|
||||
|
||||
// load scores
|
||||
@@ -1286,6 +1390,14 @@ public class SongMenu extends BasicGameState {
|
||||
songScrolling.scrollToPosition((focusNode.index + focusNode.getBeatmapSet().size() ) * buttonOffset - (footerY - headerY));
|
||||
//*/
|
||||
|
||||
// load background image
|
||||
beatmap.loadBackground();
|
||||
boolean isBgNull = lastBackgroundImage == null || beatmap.bg == null;
|
||||
if ((isBgNull && lastBackgroundImage != beatmap.bg) || (!isBgNull && !beatmap.bg.equals(lastBackgroundImage))) {
|
||||
bgAlpha.setTime(0);
|
||||
lastBackgroundImage = beatmap.bg;
|
||||
}
|
||||
|
||||
return oldFocus;
|
||||
}
|
||||
|
||||
@@ -1346,7 +1458,7 @@ public class SongMenu extends BasicGameState {
|
||||
if (scoreMap == null || scoreMap.isEmpty() || node.beatmapIndex == -1) // node not expanded
|
||||
return null;
|
||||
|
||||
Beatmap beatmap = node.getBeatmapSet().get(node.beatmapIndex);
|
||||
Beatmap beatmap = node.getSelectedBeatmap();
|
||||
ScoreData[] scores = scoreMap.get(beatmap.version);
|
||||
if (scores == null || scores.length < 1) // no scores
|
||||
return null;
|
||||
@@ -1364,6 +1476,86 @@ public class SongMenu extends BasicGameState {
|
||||
return null; // incorrect map
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads all beatmaps.
|
||||
* @param fullReload if true, also clear the beatmap cache and invoke the unpacker
|
||||
*/
|
||||
private void reloadBeatmaps(final boolean fullReload) {
|
||||
songFolderChanged = false;
|
||||
|
||||
// reset state and node references
|
||||
MusicController.reset();
|
||||
startNode = focusNode = null;
|
||||
scoreMap = null;
|
||||
focusScores = null;
|
||||
oldFocusNode = null;
|
||||
randomStack = new Stack<SongNode>();
|
||||
songInfo = null;
|
||||
hoverOffset.setTime(0);
|
||||
hoverIndex = null;
|
||||
search.setText("");
|
||||
searchTimer = SEARCH_DELAY;
|
||||
searchTransitionTimer = SEARCH_TRANSITION_TIME;
|
||||
searchResultString = null;
|
||||
lastBackgroundImage = null;
|
||||
|
||||
// reload songs in new thread
|
||||
reloadThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
File beatmapDir = Options.getBeatmapDir();
|
||||
|
||||
if (fullReload) {
|
||||
// clear the beatmap cache
|
||||
BeatmapDB.clearDatabase();
|
||||
|
||||
// invoke unpacker
|
||||
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
|
||||
}
|
||||
|
||||
// invoke parser
|
||||
BeatmapParser.parseAllFiles(beatmapDir);
|
||||
|
||||
// initialize song list
|
||||
if (BeatmapSetList.get().size() > 0) {
|
||||
BeatmapSetList.get().init();
|
||||
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
} else
|
||||
MusicController.playThemeSong();
|
||||
|
||||
reloadThread = null;
|
||||
}
|
||||
};
|
||||
reloadThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates all star ratings for a beatmap set.
|
||||
* @param beatmapSet the set of beatmaps
|
||||
*/
|
||||
private void calculateStarRatings(BeatmapSet beatmapSet) {
|
||||
for (Beatmap beatmap : beatmapSet) {
|
||||
if (beatmap.starRating >= 0) { // already calculated
|
||||
beatmapsCalculated.put(beatmap, beatmapsCalculated.get(beatmap));
|
||||
continue;
|
||||
}
|
||||
|
||||
// if timing points are already loaded before this (for whatever reason),
|
||||
// don't clear the array fields to be safe
|
||||
boolean hasTimingPoints = (beatmap.timingPoints != null);
|
||||
|
||||
BeatmapDifficultyCalculator diffCalc = new BeatmapDifficultyCalculator(beatmap);
|
||||
diffCalc.calculate();
|
||||
if (diffCalc.getStarRating() == -1)
|
||||
continue; // calculations failed
|
||||
|
||||
// save star rating
|
||||
beatmap.starRating = diffCalc.getStarRating();
|
||||
BeatmapDB.setStars(beatmap);
|
||||
beatmapsCalculated.put(beatmap, !hasTimingPoints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the game.
|
||||
*/
|
||||
@@ -1372,8 +1564,12 @@ public class SongMenu extends BasicGameState {
|
||||
return;
|
||||
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
MultiClip.destroyExtraClips();
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) {
|
||||
UI.sendBarNotification("Unable to load the beatmap audio.");
|
||||
return;
|
||||
}
|
||||
MultiClip.destroyExtraClips();
|
||||
Game gameState = (Game) game.getState(Opsu.STATE_GAME);
|
||||
gameState.loadBeatmap(beatmap);
|
||||
gameState.setRestart(Game.Restart.NEW);
|
||||
|
||||
@@ -21,21 +21,23 @@ package itdelatrisu.opsu.states;
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.OszUnpacker;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapWatchService;
|
||||
import itdelatrisu.opsu.beatmap.OszUnpacker;
|
||||
import itdelatrisu.opsu.replay.ReplayImporter;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
import org.newdawn.slick.state.BasicGameState;
|
||||
@@ -47,6 +49,9 @@ import org.newdawn.slick.state.StateBasedGame;
|
||||
* Loads game resources and enters "Main Menu" state.
|
||||
*/
|
||||
public class Splash extends BasicGameState {
|
||||
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
||||
private static final int MIN_SPLASH_TIME = 400;
|
||||
|
||||
/** Whether or not loading has completed. */
|
||||
private boolean finished = false;
|
||||
|
||||
@@ -59,8 +64,14 @@ public class Splash extends BasicGameState {
|
||||
/** Whether the skin being loaded is a new skin (for program restarts). */
|
||||
private boolean newSkin = false;
|
||||
|
||||
/** Whether the watch service is newly enabled (for program restarts). */
|
||||
private boolean watchServiceChange = false;
|
||||
|
||||
/** Logo alpha level. */
|
||||
private AnimatedValue logoAlpha;
|
||||
|
||||
// game-related variables
|
||||
private int state;
|
||||
private final int state;
|
||||
private GameContainer container;
|
||||
private boolean init = false;
|
||||
|
||||
@@ -77,9 +88,14 @@ public class Splash extends BasicGameState {
|
||||
if (Options.getSkin() != null)
|
||||
this.newSkin = (Options.getSkin().getDirectory() != Options.getSkinDir());
|
||||
|
||||
// check if watch service newly enabled
|
||||
this.watchServiceChange = Options.isWatchServiceEnabled() && BeatmapWatchService.get() == null;
|
||||
|
||||
// load Utils class first (needed in other 'init' methods)
|
||||
Utils.init(container, game);
|
||||
|
||||
// fade in logo
|
||||
this.logoAlpha = new AnimatedValue(MIN_SPLASH_TIME, 0f, 1f, AnimationEquation.LINEAR);
|
||||
GameImage.MENU_LOGO.getImage().setAlpha(0f);
|
||||
}
|
||||
|
||||
@@ -99,13 +115,18 @@ public class Splash extends BasicGameState {
|
||||
|
||||
// resources already loaded (from application restart)
|
||||
if (BeatmapSetList.get() != null) {
|
||||
// reload sounds if skin changed
|
||||
if (newSkin) {
|
||||
if (newSkin || watchServiceChange) { // need to reload resources
|
||||
thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
// reload beatmaps if watch service newly enabled
|
||||
if (watchServiceChange)
|
||||
BeatmapParser.parseAllFiles(Options.getBeatmapDir());
|
||||
|
||||
// reload sounds if skin changed
|
||||
// TODO: only reload each sound if actually needed?
|
||||
SoundController.init();
|
||||
if (newSkin)
|
||||
SoundController.init();
|
||||
|
||||
finished = true;
|
||||
thread = null;
|
||||
@@ -144,13 +165,11 @@ public class Splash extends BasicGameState {
|
||||
}
|
||||
|
||||
// fade in logo
|
||||
Image logo = GameImage.MENU_LOGO.getImage();
|
||||
float alpha = logo.getAlpha();
|
||||
if (alpha < 1f)
|
||||
logo.setAlpha(alpha + (delta / 500f));
|
||||
if (logoAlpha.update(delta))
|
||||
GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue());
|
||||
|
||||
// change states when loading complete
|
||||
if (finished && alpha >= 1f) {
|
||||
if (finished && logoAlpha.getValue() >= 1f) {
|
||||
// initialize song list
|
||||
if (BeatmapSetList.get().size() > 0) {
|
||||
BeatmapSetList.get().init();
|
||||
|
||||
Reference in New Issue
Block a user