Minor graphical changes.
- Added a simple color change when hovering over an option in the options menu. - Draw part of the song button before the start node, if any, for a more complete-looking scroll animation. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
25a7a826f1
commit
ab1a377be0
|
@ -60,9 +60,13 @@ public class OsuGroupNode {
|
||||||
* @param focus true if this is the focused node
|
* @param focus true if this is the focused node
|
||||||
*/
|
*/
|
||||||
public void draw(float x, float y, float headerY, float footerY, Grade grade, boolean focus) {
|
public void draw(float x, float y, float headerY, float footerY, Grade grade, boolean focus) {
|
||||||
|
// don't draw if out of bounds
|
||||||
|
Image bg = GameImage.MENU_BUTTON_BG.getImage();
|
||||||
|
if (y + bg.getHeight() < headerY || y > footerY)
|
||||||
|
return;
|
||||||
|
|
||||||
boolean expanded = (osuFileIndex > -1);
|
boolean expanded = (osuFileIndex > -1);
|
||||||
OsuFile osu;
|
OsuFile osu;
|
||||||
Image bg = GameImage.MENU_BUTTON_BG.getImage();
|
|
||||||
bg.setAlpha(0.9f);
|
bg.setAlpha(0.9f);
|
||||||
Color bgColor;
|
Color bgColor;
|
||||||
Color textColor = Color.lightGray;
|
Color textColor = Color.lightGray;
|
||||||
|
@ -103,11 +107,17 @@ public class OsuGroupNode {
|
||||||
cx += gradeImg.getWidth();
|
cx += gradeImg.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw text
|
// draw text (TODO: crop text)
|
||||||
|
float textY = cy;
|
||||||
|
if (textY + Utils.FONT_MEDIUM.getLineHeight() >= headerY && textY <= footerY)
|
||||||
Utils.FONT_MEDIUM.drawString(cx, cy, osu.getTitle(), textColor);
|
Utils.FONT_MEDIUM.drawString(cx, cy, osu.getTitle(), textColor);
|
||||||
|
textY += Utils.FONT_MEDIUM.getLineHeight() - 4;
|
||||||
|
if (textY + Utils.FONT_MEDIUM.getLineHeight() >= headerY && textY <= footerY)
|
||||||
Utils.FONT_DEFAULT.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() - 4,
|
Utils.FONT_DEFAULT.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() - 4,
|
||||||
String.format("%s // %s", osu.getArtist(), osu.creator), textColor);
|
String.format("%s // %s", osu.getArtist(), osu.creator), textColor);
|
||||||
if (expanded || osuFiles.size() == 1)
|
textY += Utils.FONT_MEDIUM.getLineHeight() - 4;
|
||||||
|
if ((textY + Utils.FONT_BOLD.getLeading() >= headerY && textY <= footerY) &&
|
||||||
|
(expanded || osuFiles.size() == 1))
|
||||||
Utils.FONT_BOLD.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8,
|
Utils.FONT_BOLD.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8,
|
||||||
osu.version, textColor);
|
osu.version, textColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,8 +202,13 @@ public class OptionsMenu extends BasicGameState {
|
||||||
|
|
||||||
// game options
|
// game options
|
||||||
g.setLineWidth(1f);
|
g.setLineWidth(1f);
|
||||||
for (int i = 0; i < currentTab.options.length; i++)
|
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
||||||
drawOption(currentTab.options[i], i);
|
(keyEntryRight) ? GameOption.KEY_RIGHT :
|
||||||
|
getOptionAt(mouseY);
|
||||||
|
for (int i = 0; i < currentTab.options.length; i++) {
|
||||||
|
GameOption option = currentTab.options[i];
|
||||||
|
drawOption(option, i, hoverOption == option);
|
||||||
|
}
|
||||||
|
|
||||||
// option tabs
|
// option tabs
|
||||||
OptionTab hoverTab = null;
|
OptionTab hoverTab = null;
|
||||||
|
@ -287,7 +292,7 @@ public class OptionsMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// options (click only)
|
// options (click only)
|
||||||
GameOption option = getClickedOption(y);
|
GameOption option = getOptionAt(y);
|
||||||
if (option != GameOption.NULL)
|
if (option != GameOption.NULL)
|
||||||
option.click(container);
|
option.click(container);
|
||||||
|
|
||||||
|
@ -323,7 +328,7 @@ public class OptionsMenu extends BasicGameState {
|
||||||
diff = ((diff > 0) ? 1 : -1) * multiplier;
|
diff = ((diff > 0) ? 1 : -1) * multiplier;
|
||||||
|
|
||||||
// options (drag only)
|
// options (drag only)
|
||||||
GameOption option = getClickedOption(oldy);
|
GameOption option = getOptionAt(oldy);
|
||||||
if (option != GameOption.NULL)
|
if (option != GameOption.NULL)
|
||||||
option.drag(container, diff);
|
option.drag(container, diff);
|
||||||
}
|
}
|
||||||
|
@ -380,26 +385,27 @@ public class OptionsMenu extends BasicGameState {
|
||||||
* Draws a game option.
|
* Draws a game option.
|
||||||
* @param option the option
|
* @param option the option
|
||||||
* @param pos the position to draw at
|
* @param pos the position to draw at
|
||||||
|
* @param focus whether the option is currently focused
|
||||||
*/
|
*/
|
||||||
private void drawOption(GameOption option, int pos) {
|
private void drawOption(GameOption option, int pos, boolean focus) {
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int textHeight = Utils.FONT_LARGE.getLineHeight();
|
int textHeight = Utils.FONT_LARGE.getLineHeight();
|
||||||
float y = textY + (pos * offsetY);
|
float y = textY + (pos * offsetY);
|
||||||
|
Color color = (focus) ? Color.cyan : Color.white;
|
||||||
|
|
||||||
Utils.FONT_LARGE.drawString(width / 30, y, option.getName(), Color.white);
|
Utils.FONT_LARGE.drawString(width / 30, y, option.getName(), color);
|
||||||
Utils.FONT_LARGE.drawString(width / 2, y, option.getValueString(), Color.white);
|
Utils.FONT_LARGE.drawString(width / 2, y, option.getValueString(), color);
|
||||||
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, option.getDescription(), Color.white);
|
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
||||||
g.setColor(Utils.COLOR_WHITE_ALPHA);
|
g.setColor(Utils.COLOR_WHITE_ALPHA);
|
||||||
g.drawLine(0, y + textHeight, width, y + textHeight);
|
g.drawLine(0, y + textHeight, width, y + textHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the option clicked.
|
* Returns the option at the given y coordinate.
|
||||||
* If no option clicked, -1 will be returned.
|
|
||||||
* @param y the y coordinate
|
* @param y the y coordinate
|
||||||
* @return the option
|
* @return the option, or GameOption.NULL if no such option exists
|
||||||
*/
|
*/
|
||||||
private GameOption getClickedOption(int y) {
|
private GameOption getOptionAt(int y) {
|
||||||
GameOption option = GameOption.NULL;
|
GameOption option = GameOption.NULL;
|
||||||
|
|
||||||
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
||||||
|
|
|
@ -329,12 +329,17 @@ public class SongMenu extends BasicGameState {
|
||||||
|
|
||||||
// song buttons
|
// song buttons
|
||||||
OsuGroupNode node = startNode;
|
OsuGroupNode node = startNode;
|
||||||
for (int i = 0; i < MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
|
int songButtonIndex = 0;
|
||||||
|
if (node != null && node.prev != null) {
|
||||||
|
node = node.prev;
|
||||||
|
songButtonIndex = -1;
|
||||||
|
}
|
||||||
|
for (int i = songButtonIndex; i <= MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
|
||||||
// draw the node
|
// draw the node
|
||||||
float offset = (i == hoverIndex) ? hoverOffset : 0f;
|
float offset = (i == hoverIndex) ? hoverOffset : 0f;
|
||||||
ScoreData[] scores = getScoreDataForNode(node, false);
|
ScoreData[] scores = getScoreDataForNode(node, false);
|
||||||
node.draw(
|
node.draw(
|
||||||
buttonX - offset, buttonY + (i*buttonOffset),
|
buttonX - offset, buttonY + (i*buttonOffset) + DIVIDER_LINE_WIDTH / 2,
|
||||||
headerY + DIVIDER_LINE_WIDTH / 2, footerY - DIVIDER_LINE_WIDTH,
|
headerY + DIVIDER_LINE_WIDTH / 2, footerY - DIVIDER_LINE_WIDTH,
|
||||||
(scores == null) ? Grade.NULL : scores[0].getGrade(),
|
(scores == null) ? Grade.NULL : scores[0].getGrade(),
|
||||||
(node == focusNode)
|
(node == focusNode)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user