Added mouse hover effects for tabs.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
6e434e9709
commit
5a09689b4c
|
@ -195,8 +195,9 @@ public enum SongSort {
|
||||||
/**
|
/**
|
||||||
* Draws the sort tab.
|
* Draws the sort tab.
|
||||||
* @param selected whether the tab is selected (white) or not (red)
|
* @param selected whether the tab is selected (white) or not (red)
|
||||||
|
* @param isHover whether to include a hover effect (unselected only)
|
||||||
*/
|
*/
|
||||||
public void draw(boolean selected) {
|
public void draw(boolean selected, boolean isHover) {
|
||||||
Utils.drawTab(tab.getX(), tab.getY(), name, selected);
|
Utils.drawTab(tab.getX(), tab.getY(), name, selected, isHover);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -66,7 +66,8 @@ public class Utils {
|
||||||
COLOR_RED_OBJECT = new Color(243, 48, 77),
|
COLOR_RED_OBJECT = new Color(243, 48, 77),
|
||||||
COLOR_ORANGE_OBJECT = new Color(255, 200, 32),
|
COLOR_ORANGE_OBJECT = new Color(255, 200, 32),
|
||||||
COLOR_YELLOW_ALPHA = new Color(255, 255, 0, 0.4f),
|
COLOR_YELLOW_ALPHA = new Color(255, 255, 0, 0.4f),
|
||||||
COLOR_WHITE_FADE = new Color(255, 255, 255, 1f);
|
COLOR_WHITE_FADE = new Color(255, 255, 255, 1f),
|
||||||
|
COLOR_RED_HOVER = new Color(255, 112, 112);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default map colors, used when a map does not provide custom colors.
|
* The default map colors, used when a map does not provide custom colors.
|
||||||
|
@ -217,8 +218,9 @@ public class Utils {
|
||||||
* @param y the center y coordinate
|
* @param y the center y coordinate
|
||||||
* @param text the text to draw inside the tab
|
* @param text the text to draw inside the tab
|
||||||
* @param selected whether the tab is selected (white) or not (red)
|
* @param selected whether the tab is selected (white) or not (red)
|
||||||
|
* @param isHover whether to include a hover effect (unselected only)
|
||||||
*/
|
*/
|
||||||
public static void drawTab(float x, float y, String text, boolean selected) {
|
public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) {
|
||||||
Image tabImage = GameImage.MENU_TAB.getImage();
|
Image tabImage = GameImage.MENU_TAB.getImage();
|
||||||
float tabTextX = x - (Utils.FONT_MEDIUM.getWidth(text) / 2);
|
float tabTextX = x - (Utils.FONT_MEDIUM.getWidth(text) / 2);
|
||||||
float tabTextY = y - (tabImage.getHeight() / 2f) +
|
float tabTextY = y - (tabImage.getHeight() / 2f) +
|
||||||
|
@ -228,7 +230,7 @@ public class Utils {
|
||||||
filter = Color.white;
|
filter = Color.white;
|
||||||
textColor = Color.black;
|
textColor = Color.black;
|
||||||
} else {
|
} else {
|
||||||
filter = Color.red;
|
filter = (isHover) ? Utils.COLOR_RED_HOVER : Color.red;
|
||||||
textColor = Color.white;
|
textColor = Color.white;
|
||||||
}
|
}
|
||||||
Utils.drawCentered(tabImage, x, y, filter);
|
Utils.drawCentered(tabImage, x, y, filter);
|
||||||
|
|
|
@ -453,6 +453,7 @@ public class Options extends BasicGameState {
|
||||||
|
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||||
|
|
||||||
// title
|
// title
|
||||||
Utils.FONT_XLARGE.drawString(
|
Utils.FONT_XLARGE.drawString(
|
||||||
|
@ -487,11 +488,20 @@ public class Options extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// option tabs
|
// option tabs
|
||||||
|
int hoverTab = -1;
|
||||||
|
for (int i = 0; i < optionTabs.length; i++) {
|
||||||
|
if (optionTabs[i].contains(mouseX, mouseY)) {
|
||||||
|
hoverTab = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (int i = optionTabs.length - 1; i >= 0; i--) {
|
for (int i = optionTabs.length - 1; i >= 0; i--) {
|
||||||
if (i != currentTab)
|
if (i != currentTab)
|
||||||
Utils.drawTab(optionTabs[i].getX(), optionTabs[i].getY(), TAB_NAMES[i], false);
|
Utils.drawTab(optionTabs[i].getX(), optionTabs[i].getY(),
|
||||||
|
TAB_NAMES[i], false, i == hoverTab);
|
||||||
}
|
}
|
||||||
Utils.drawTab(optionTabs[currentTab].getX(), optionTabs[currentTab].getY(), TAB_NAMES[currentTab], true);
|
Utils.drawTab(optionTabs[currentTab].getX(), optionTabs[currentTab].getY(),
|
||||||
|
TAB_NAMES[currentTab], true, false);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.setLineWidth(2f);
|
g.setLineWidth(2f);
|
||||||
float lineY = optionTabs[0].getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
float lineY = optionTabs[0].getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
||||||
|
|
|
@ -204,6 +204,7 @@ public class SongMenu extends BasicGameState {
|
||||||
|
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||||
|
|
||||||
// background
|
// background
|
||||||
if (focusNode != null)
|
if (focusNode != null)
|
||||||
|
@ -255,11 +256,18 @@ public class SongMenu extends BasicGameState {
|
||||||
|
|
||||||
// sorting tabs
|
// sorting tabs
|
||||||
SongSort currentSort = SongSort.getSort();
|
SongSort currentSort = SongSort.getSort();
|
||||||
|
SongSort hoverSort = null;
|
||||||
|
for (SongSort sort : SongSort.values()) {
|
||||||
|
if (sort.contains(mouseX, mouseY)) {
|
||||||
|
hoverSort = sort;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (SongSort sort : SongSort.VALUES_REVERSED) {
|
for (SongSort sort : SongSort.VALUES_REVERSED) {
|
||||||
if (sort != currentSort)
|
if (sort != currentSort)
|
||||||
sort.draw(false);
|
sort.draw(false, sort == hoverSort);
|
||||||
}
|
}
|
||||||
currentSort.draw(true);
|
currentSort.draw(true, false);
|
||||||
|
|
||||||
// search
|
// search
|
||||||
Image searchIcon = GameImage.MENU_SEARCH.getImage();
|
Image searchIcon = GameImage.MENU_SEARCH.getImage();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user