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
|
||||
*/
|
||||
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);
|
||||
OsuFile osu;
|
||||
Image bg = GameImage.MENU_BUTTON_BG.getImage();
|
||||
bg.setAlpha(0.9f);
|
||||
Color bgColor;
|
||||
Color textColor = Color.lightGray;
|
||||
|
@ -103,11 +107,17 @@ public class OsuGroupNode {
|
|||
cx += gradeImg.getWidth();
|
||||
}
|
||||
|
||||
// draw text
|
||||
Utils.FONT_MEDIUM.drawString(cx, cy, osu.getTitle(), textColor);
|
||||
Utils.FONT_DEFAULT.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() - 4,
|
||||
String.format("%s // %s", osu.getArtist(), osu.creator), textColor);
|
||||
if (expanded || osuFiles.size() == 1)
|
||||
// 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);
|
||||
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,
|
||||
String.format("%s // %s", osu.getArtist(), osu.creator), textColor);
|
||||
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,
|
||||
osu.version, textColor);
|
||||
}
|
||||
|
|
|
@ -202,8 +202,13 @@ public class OptionsMenu extends BasicGameState {
|
|||
|
||||
// game options
|
||||
g.setLineWidth(1f);
|
||||
for (int i = 0; i < currentTab.options.length; i++)
|
||||
drawOption(currentTab.options[i], i);
|
||||
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
||||
(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
|
||||
OptionTab hoverTab = null;
|
||||
|
@ -287,7 +292,7 @@ public class OptionsMenu extends BasicGameState {
|
|||
}
|
||||
|
||||
// options (click only)
|
||||
GameOption option = getClickedOption(y);
|
||||
GameOption option = getOptionAt(y);
|
||||
if (option != GameOption.NULL)
|
||||
option.click(container);
|
||||
|
||||
|
@ -323,7 +328,7 @@ public class OptionsMenu extends BasicGameState {
|
|||
diff = ((diff > 0) ? 1 : -1) * multiplier;
|
||||
|
||||
// options (drag only)
|
||||
GameOption option = getClickedOption(oldy);
|
||||
GameOption option = getOptionAt(oldy);
|
||||
if (option != GameOption.NULL)
|
||||
option.drag(container, diff);
|
||||
}
|
||||
|
@ -380,26 +385,27 @@ public class OptionsMenu extends BasicGameState {
|
|||
* Draws a game option.
|
||||
* @param option the option
|
||||
* @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 textHeight = Utils.FONT_LARGE.getLineHeight();
|
||||
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 / 2, y, option.getValueString(), Color.white);
|
||||
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, option.getDescription(), 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);
|
||||
g.drawLine(0, y + textHeight, width, y + textHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the option clicked.
|
||||
* If no option clicked, -1 will be returned.
|
||||
* Returns the option at the given 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;
|
||||
|
||||
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
||||
|
|
|
@ -329,12 +329,17 @@ public class SongMenu extends BasicGameState {
|
|||
|
||||
// song buttons
|
||||
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
|
||||
float offset = (i == hoverIndex) ? hoverOffset : 0f;
|
||||
ScoreData[] scores = getScoreDataForNode(node, false);
|
||||
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,
|
||||
(scores == null) ? Grade.NULL : scores[0].getGrade(),
|
||||
(node == focusNode)
|
||||
|
|
Loading…
Reference in New Issue
Block a user