Skip to content

Commit

Permalink
User system improvements (edit/delete menu + new icons).
Browse files Browse the repository at this point in the history
* Right-click on any user to open the "Edit User" menu. Users can now be deleted and icons can be changed.
* Replaced the 3 existing icons with 15 new ones from freepik.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
  • Loading branch information
itdelatrisu committed Apr 21, 2018
1 parent 019f577 commit 0599e2c
Show file tree
Hide file tree
Showing 19 changed files with 213 additions and 39 deletions.
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ The images included in opsu! belong to their respective authors.
* kouyang
* teinecthel
* Teddy Kelley - https://unsplash.com/photos/weuWmzv7xnU (main menu background)
* User icons ("User", "Male User", "Female User") by To Uyen from the Noun Project
* User icons designed by Freepik - https://www.freepik.com/
* https://www.freepik.com/free-vector/flat-lovely-animal-avatar-collection_845660.htm
* https://www.freepik.com/free-vector/wild-and-marine-animal-collection_845661.htm
* Font Awesome by Dave Gandy - http://fontawesome.io

Projects
Expand Down
Binary file modified res/user0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/user1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/user2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/user9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 24 additions & 4 deletions src/itdelatrisu/opsu/user/UserButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class UserButton {
/** The user. */
private User user;

/** Placeholder text to display if {@link #user} is null. */
private String placeholderText;

/**
* Initializes the user buttons.
* @param width the container width
Expand Down Expand Up @@ -124,6 +127,14 @@ public void setUser(User user) {
/** Returns the user. */
public User getUser() { return user; }

/** Sets the text to display if no user is set. */
public void setPlaceholderText(String placeholderText) {
this.placeholderText = placeholderText;
}

/** Returns the placeholder text. */
public String getPlaceholderText() { return placeholderText; }

/**
* Returns true if the coordinates are within the button bounds.
* @param cx the x coordinate
Expand Down Expand Up @@ -164,12 +175,11 @@ public void draw(Graphics g, float alpha) {
g.fillRoundRect(cx, cy, buttonWidth - padding * 2, buttonHeight - padding * 2, 4);

// no user?
if (user == null) {
String text = "Add User";
if (user == null && placeholderText != null) {
Fonts.LARGE.drawString(
x + (buttonWidth - Fonts.LARGE.getWidth(text)) / 2,
x + (buttonWidth - Fonts.LARGE.getWidth(placeholderText)) / 2,
y + (buttonHeight - Fonts.LARGE.getLineHeight()) / 2,
text, Colors.WHITE_FADE
placeholderText, Colors.WHITE_FADE
);
Colors.WHITE_FADE.a = oldWhiteAlpha;
return;
Expand Down Expand Up @@ -248,6 +258,16 @@ public void setHoverAnimationEquation(AnimationEquation eqn) {
bgAlpha.setEquation(eqn);
}

/**
* Sets the hover animation base value.
* @param base the base value
*/
public void setHoverAnimationBase(float base) {
AnimatedValue value = new AnimatedValue(bgAlpha.getDuration(), base, 1f, bgAlpha.getEquation());
value.setTime(bgAlpha.getTime());
bgAlpha = value;
}

/** Resets the hover fields for the button. */
public void resetHover() {
bgAlpha.setTime(0);
Expand Down
17 changes: 17 additions & 0 deletions src/itdelatrisu/opsu/user/UserList.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public UserList() {
}
}

/** Returns the number of users. */
public int size() { return users.size(); }

/** Returns all users. */
public List<User> getUsers() {
List<User> l = new ArrayList<User>(users.values());
Expand Down Expand Up @@ -126,6 +129,20 @@ public User createNewUser(String name, int icon) {
return user;
}

/**
* Deletes the given user.
* @param name the user's name
* @return true if the user was deleted, false otherwise
*/
public boolean deleteUser(String name) {
if (!userExists(name) || name.equals(currentUser.getName()))
return false;

ScoreDB.deleteUser(name);
users.remove(name.toLowerCase());
return true;
}

/** Returns whether the given name is a valid user name. */
public boolean isValidUserName(String name) {
return !name.isEmpty() && name.length() <= MAX_USER_NAME_LENGTH &&
Expand Down
Loading

0 comments on commit 0599e2c

Please sign in to comment.