Skip to content

Commit

Permalink
Minor formatting cleanup for #131.
Browse files Browse the repository at this point in the history
Also made some members private.

Signed-off-by: Jeffrey Han <[email protected]>
  • Loading branch information
itdelatrisu committed Sep 16, 2015
1 parent e1becb3 commit e0da6a2
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 126 deletions.
12 changes: 5 additions & 7 deletions src/itdelatrisu/opsu/ScoreData.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ public static void init(int containerWidth, float topY) {
/**
* Returns the Buttons Offset
*/
public static float getButtonOffset() {
return buttonOffset;
}

public static float getButtonOffset() { return buttonOffset; }

/**
* Returns true if the coordinates are within the bounds of the
* button at the given index.
Expand Down Expand Up @@ -136,14 +134,14 @@ public static boolean areaContains(float cx, float cy) {
/**
* Draws the scroll bar for the score buttons.
* @param g the graphics context
* @param index the start button index
* @param pos the start button index
* @param total the total number of buttons
*/
public static void drawScrollbar(Graphics g, float pos, float total) {
UI.drawScrollbar(g, pos, total, SongMenu.MAX_SCORE_BUTTONS * buttonOffset, 0, baseY,
0, buttonAreaHeight, null, Color.white, false);
}

/**
* Sets a clip to the area.
* @param g the graphics context
Expand Down Expand Up @@ -238,7 +236,7 @@ else if (seconds < 86400)
/**
* Draws the score data as a rectangular button.
* @param g the graphics context
* @param index the index (to offset the button from the topmost button)
* @param position the index (to offset the button from the topmost button)
* @param rank the score rank
* @param prevScore the previous (lower) score, or -1 if none
* @param focus whether the button is focused
Expand Down
25 changes: 11 additions & 14 deletions src/itdelatrisu/opsu/downloads/DownloadNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static boolean resultAreaContains(float cx, float cy) {
public static void clipToResultArea(Graphics g) {
g.setClip((int) buttonBaseX, (int) buttonBaseY, (int) buttonWidth, (int) (buttonOffset * maxResultsShown));
}

/**
* Sets a clip to the download area.
* @param g the graphics context
Expand Down Expand Up @@ -192,20 +192,17 @@ public static boolean downloadIconContains(float cx, float cy, int index) {
}

/**
* Returns the button(Results) offset.
* @return the button offset
* Returns the download results button offset.
* @return the offset
*/
public static float getButtonOffset(){
return buttonOffset;
}

public static float getButtonOffset() { return buttonOffset; }

/**
* Returns the info(Download) height.
* @return the infoHeight
* Returns the download info height.
* @return the height
*/
public static float getInfoHeight(){
return infoHeight;
}
public static float getInfoHeight() { return infoHeight; }

/**
* Returns true if the coordinates are within the bounds of the
* download information button area.
Expand All @@ -224,8 +221,8 @@ public static boolean downloadAreaContains(float cx, float cy) {
* @param total the total number of buttons
*/
public static void drawResultScrollbar(Graphics g, float position, float total) {
UI.drawScrollbar(g, position, total, maxResultsShown * buttonOffset, buttonBaseX, buttonBaseY,
buttonWidth * 1.01f, (maxResultsShown-1) * buttonOffset + buttonHeight,
UI.drawScrollbar(g, position, total, maxResultsShown * buttonOffset, buttonBaseX, buttonBaseY,
buttonWidth * 1.01f, (maxResultsShown-1) * buttonOffset + buttonHeight,
Colors.BLACK_BG_NORMAL, Color.white, true);
}

Expand Down
43 changes: 20 additions & 23 deletions src/itdelatrisu/opsu/states/DownloadsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class DownloadsMenu extends BasicGameState {
private int focusTimer = 0;

/** Current start result button (topmost entry). */
KineticScrolling startResultPos = new KineticScrolling();
private KineticScrolling startResultPos = new KineticScrolling();

/** Total number of results for current query. */
private int totalResults = 0;
Expand All @@ -116,7 +116,7 @@ private enum Page { RESET, CURRENT, PREVIOUS, NEXT };
private boolean rankedOnly = true;

/** Current start download index. */
KineticScrolling startDownloadIndexPos = new KineticScrolling();
private KineticScrolling startDownloadIndexPos = new KineticScrolling();

/** Query thread. */
private Thread queryThread;
Expand Down Expand Up @@ -396,15 +396,15 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)
int maxResultsShown = DownloadNode.maxResultsShown();
int startResult = (int) (startResultPos.getPosition() / DownloadNode.getButtonOffset());
int offset = (int) (-startResultPos.getPosition() + startResult * DownloadNode.getButtonOffset());

for (int i = 0; i < maxResultsShown + 1; i++) {
int index = startResult + i;
if(index < 0)
if (index < 0)
continue;
if (index >= nodes.length)
break;
nodes[index].drawResult(g, offset + i * DownloadNode.getButtonOffset(),
DownloadNode.resultContains(mouseX, mouseY - offset, i) && !inDropdownMenu,
DownloadNode.resultContains(mouseX, mouseY - offset, i) && !inDropdownMenu,
(index == focusResult), (previewID == nodes[index].getID()));
}
g.clearClip();
Expand Down Expand Up @@ -441,21 +441,20 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)
int maxDownloadsShown = DownloadNode.maxDownloadsShown();
int startDownloadIndex = (int) (startDownloadIndexPos.getPosition() / DownloadNode.getInfoHeight());
int offset = (int) (-startDownloadIndexPos.getPosition() + startDownloadIndex * DownloadNode.getInfoHeight());

DownloadNode.clipToDownloadArea(g);
for (int i = 0; i < maxDownloadsShown + 1; i++) {
int index = startDownloadIndex + i;
if (index >= downloadsSize)
break;
DownloadNode node = DownloadList.get().getNode(index);
if (node == null)
break;
node.drawDownload(g, i * DownloadNode.getInfoHeight() + offset, index,
DownloadNode.downloadContains(mouseX, mouseY - offset, i));
}
for (int i = 0; i < maxDownloadsShown + 1; i++) {
int index = startDownloadIndex + i;
if (index >= downloadsSize)
break;
DownloadNode node = DownloadList.get().getNode(index);
if (node == null)
break;
node.drawDownload(g, i * DownloadNode.getInfoHeight() + offset, index,
DownloadNode.downloadContains(mouseX, mouseY - offset, i));
}
g.clearClip();


// scroll bar
if (downloadsSize > maxDownloadsShown)
DownloadNode.drawDownloadScrollbar(g, startDownloadIndexPos.getPosition(), downloadsSize * DownloadNode.getInfoHeight());
Expand Down Expand Up @@ -508,7 +507,7 @@ public void update(GameContainer container, StateBasedGame game, int delta)
if (resultList != null)
startResultPos.setMinMax(0, DownloadNode.getButtonOffset() * (resultList.length - DownloadNode.maxResultsShown()));
startResultPos.update(delta);

// focus timer
if (focusResult != -1 && focusTimer < FOCUS_DELAY)
focusTimer += delta;
Expand Down Expand Up @@ -579,7 +578,7 @@ public void mousePressed(int button, int x, int y) {
for (int i = 0; i < maxResultsShown + 1; i++) {
int startResult = (int) (startResultPos.getPosition() / DownloadNode.getButtonOffset());
int offset = (int) (-startResultPos.getPosition() + startResult * DownloadNode.getButtonOffset());

int index = startResult + i;
if (index >= nodes.length)
break;
Expand Down Expand Up @@ -946,14 +945,12 @@ private void resetSearchTimer() {
*/
private void scrollLists(int cx, int cy, int shift) {
// search results
if (DownloadNode.resultAreaContains(cx, cy)) {
if (DownloadNode.resultAreaContains(cx, cy))
startResultPos.scrollOffset(shift * DownloadNode.getButtonOffset());
}

// downloads
else if (DownloadNode.downloadAreaContains(cx, cy)) {
else if (DownloadNode.downloadAreaContains(cx, cy))
startDownloadIndexPos.scrollOffset(shift * DownloadNode.getInfoHeight());
}
}

/**
Expand Down
Loading

0 comments on commit e0da6a2

Please sign in to comment.