more easier access to common variables

This commit is contained in:
yugecin 2018-07-08 00:47:35 +02:00
parent 4338513180
commit 0fc2008f2a
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44
19 changed files with 76 additions and 107 deletions

View File

@ -363,13 +363,13 @@ public class Slider extends GameObject {
float followCircleScale = 1f + (tickExpandTime / (float) TICK_EXPAND_TIME) * 0.1f; float followCircleScale = 1f + (tickExpandTime / (float) TICK_EXPAND_TIME) * 0.1f;
float followAlpha = 1f; float followAlpha = 1f;
if (followCircleActive && followExpandTime < FOLLOW_EXPAND_TIME) { if (followCircleActive && followExpandTime < FOLLOW_EXPAND_TIME) {
followExpandTime += displayContainer.renderDelta; followExpandTime += renderDelta;
followCircleScale *= 0.5f; followCircleScale *= 0.5f;
float progress = AnimationEquation.OUT_QUAD.calc((float) followExpandTime / FOLLOW_EXPAND_TIME); float progress = AnimationEquation.OUT_QUAD.calc((float) followExpandTime / FOLLOW_EXPAND_TIME);
followCircleScale = followCircleScale + followCircleScale * progress; followCircleScale = followCircleScale + followCircleScale * progress;
followAlpha = progress; followAlpha = progress;
} else if (!followCircleActive) { } else if (!followCircleActive) {
followExpandTime -= displayContainer.renderDelta; followExpandTime -= renderDelta;
if (followExpandTime > FOLLOW_SHRINK_TIME) { if (followExpandTime > FOLLOW_SHRINK_TIME) {
followExpandTime = FOLLOW_SHRINK_TIME; followExpandTime = FOLLOW_SHRINK_TIME;
} }

View File

@ -226,14 +226,14 @@ public class ButtonMenu extends BaseOpsuState {
super.preRenderUpdate(); super.preRenderUpdate();
GameMod hoverMod = null; GameMod hoverMod = null;
for (GameMod mod : GameMod.values()) { for (GameMod mod : GameMod.values()) {
mod.hoverUpdate(displayContainer.renderDelta, mod.isActive()); mod.hoverUpdate(renderDelta, mod.isActive());
if (hoverMod == null && mod.contains(displayContainer.mouseX, displayContainer.mouseY)) if (hoverMod == null && mod.contains(mouseX, mouseY))
hoverMod = mod; hoverMod = mod;
} }
// tooltips // tooltips
if (hoverMod != null) { if (hoverMod != null) {
UI.updateTooltip(displayContainer.renderDelta, hoverMod.getDescription(), true); UI.updateTooltip(renderDelta, hoverMod.getDescription(), true);
} }
} }
@ -340,11 +340,11 @@ public class ButtonMenu extends BaseOpsuState {
* Updates the menu state. * Updates the menu state.
*/ */
public void preRenderUpdate() { public void preRenderUpdate() {
boolean centerOffsetUpdated = centerOffset.update(displayContainer.renderDelta); boolean centerOffsetUpdated = centerOffset.update(renderDelta);
float centerOffsetX = centerOffset.getValue(); float centerOffsetX = centerOffset.getValue();
final float[] offsets = { centerOffsetX, - centerOffsetX }; final float[] offsets = { centerOffsetX, - centerOffsetX };
for (int i = 0; i < buttons.length; i++) { for (int i = 0; i < buttons.length; i++) {
menuButtons[i].hoverUpdate(displayContainer.renderDelta, displayContainer.mouseX, displayContainer.mouseY); menuButtons[i].hoverUpdate(renderDelta, mouseX, mouseY);
// move button to center // move button to center
if (centerOffsetUpdated) { if (centerOffsetUpdated) {
@ -622,7 +622,7 @@ public class ButtonMenu extends BaseOpsuState {
public void preRenderUpdate() { public void preRenderUpdate() {
super.preRenderUpdate(); super.preRenderUpdate();
UI.update(displayContainer.renderDelta); UI.update(renderDelta);
MusicController.loopTrackIfEnded(false); MusicController.loopTrackIfEnded(false);
menuState.preRenderUpdate(); menuState.preRenderUpdate();
} }

View File

@ -364,7 +364,7 @@ public class DownloadsMenu extends ComplexOpsuState {
// dropdown menu // dropdown menu
int serverWidth = (int) (width * 0.12f); int serverWidth = (int) (width * 0.12f);
int x = baseX + searchWidth + buttonMarginX * 3 + resetButtonWidth + rankedButtonWidth; int x = baseX + searchWidth + buttonMarginX * 3 + resetButtonWidth + rankedButtonWidth;
serverMenu = new DropdownMenu<DownloadServer>(displayContainer, SERVERS, x, searchY, serverWidth) { serverMenu = new DropdownMenu<DownloadServer>(SERVERS, x, searchY, serverWidth) {
@Override @Override
public void itemSelected(int index, DownloadServer item) { public void itemSelected(int index, DownloadServer item) {
resultList = null; resultList = null;
@ -433,7 +433,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (index >= nodes.length) if (index >= nodes.length)
break; break;
nodes[index].drawResult(g, offset + i * DownloadNode.getButtonOffset(), nodes[index].drawResult(g, offset + i * DownloadNode.getButtonOffset(),
DownloadNode.resultContains(displayContainer.mouseX, displayContainer.mouseY - offset, i) && !serverMenu.isHovered(), DownloadNode.resultContains(mouseX, mouseY - offset, i) && !serverMenu.isHovered(),
(index == focusResult), (previewID == nodes[index].getID())); (index == focusResult), (previewID == nodes[index].getID()));
} }
g.clearClip(); g.clearClip();
@ -479,7 +479,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (node == null) if (node == null)
break; break;
node.drawDownload(g, i * DownloadNode.getInfoHeight() + offset, index, node.drawDownload(g, i * DownloadNode.getInfoHeight() + offset, index,
DownloadNode.downloadContains(displayContainer.mouseX, displayContainer.mouseY - offset, i)); DownloadNode.downloadContains(mouseX, mouseY - offset, i));
} }
g.clearClip(); g.clearClip();
@ -516,7 +516,7 @@ public class DownloadsMenu extends ComplexOpsuState {
public void preRenderUpdate() { public void preRenderUpdate() {
super.preRenderUpdate(); super.preRenderUpdate();
int delta = displayContainer.renderDelta; int delta = renderDelta;
UI.update(delta); UI.update(delta);
if (importThread == null) if (importThread == null)
MusicController.loopTrackIfEnded(false); MusicController.loopTrackIfEnded(false);
@ -537,8 +537,6 @@ public class DownloadsMenu extends ComplexOpsuState {
} }
importThread = null; importThread = null;
} }
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
backButton.hoverUpdate(delta, mouseX, mouseY); backButton.hoverUpdate(delta, mouseX, mouseY);
prevPage.hoverUpdate(delta, mouseX, mouseY); prevPage.hoverUpdate(delta, mouseX, mouseY);
nextPage.hoverUpdate(delta, mouseX, mouseY); nextPage.hoverUpdate(delta, mouseX, mouseY);
@ -846,7 +844,7 @@ public class DownloadsMenu extends ComplexOpsuState {
} }
int shift = (newValue < 0) ? 1 : -1; int shift = (newValue < 0) ? 1 : -1;
scrollLists(displayContainer.mouseX, displayContainer.mouseY, shift); scrollLists(mouseX, mouseY, shift);
return true; return true;
} }

View File

@ -316,8 +316,8 @@ public class Game extends ComplexOpsuState {
public Game() { public Game() {
super(); super();
mirrorCursor = new Cursor(true); mirrorCursor = new Cursor(true);
this.moveStoryboardOverlay = new MoveStoryboard(displayContainer); this.moveStoryboardOverlay = new MoveStoryboard();
this.optionsOverlay = new OptionsOverlay(displayContainer, OptionGroups.storyboardOptions); this.optionsOverlay = new OptionsOverlay(OptionGroups.storyboardOptions);
this.storyboardOverlay = new StoryboardOverlay(moveStoryboardOverlay, optionsOverlay, this); this.storyboardOverlay = new StoryboardOverlay(moveStoryboardOverlay, optionsOverlay, this);
storyboardOverlay.show(); storyboardOverlay.show();
moveStoryboardOverlay.show(); moveStoryboardOverlay.show();
@ -448,23 +448,23 @@ public class Game extends ComplexOpsuState {
// draw alpha map around cursor // draw alpha map around cursor
g.setDrawMode(Graphics.MODE_ALPHA_MAP); g.setDrawMode(Graphics.MODE_ALPHA_MAP);
g.clearAlphaMap(); g.clearAlphaMap();
int mouseX, mouseY; int mx, my;
if (pauseTime > -1 && pausedMousePosition != null) { if (pauseTime > -1 && pausedMousePosition != null) {
mouseX = (int) pausedMousePosition.x; mx = (int) pausedMousePosition.x;
mouseY = (int) pausedMousePosition.y; my = (int) pausedMousePosition.y;
} else if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) { } else if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
mouseX = (int) autoMousePosition.x; mx = (int) autoMousePosition.x;
mouseY = (int) autoMousePosition.y; my = (int) autoMousePosition.y;
} else if (isReplay) { } else if (isReplay) {
mouseX = replayX; mx = replayX;
mouseY = replayY; my = replayY;
} else { } else {
mouseX = displayContainer.mouseX; mx = mouseX;
mouseY = displayContainer.mouseY; my = mouseY;
} }
int alphaRadius = flashlightRadius * 256 / 215; int alphaRadius = flashlightRadius * 256 / 215;
int alphaX = mouseX - alphaRadius / 2; int alphaX = mx - alphaRadius / 2;
int alphaY = mouseY - alphaRadius / 2; int alphaY = my - alphaRadius / 2;
GameImage.ALPHA_MAP.getImage().draw(alphaX, alphaY, alphaRadius, alphaRadius); GameImage.ALPHA_MAP.getImage().draw(alphaX, alphaY, alphaRadius, alphaRadius);
// blend offscreen image // blend offscreen image
@ -676,7 +676,7 @@ public class Game extends ComplexOpsuState {
// draw music position bar (for replay seeking) // draw music position bar (for replay seeking)
if (isReplay && OPTION_REPLAY_SEEKING.state) { if (isReplay && OPTION_REPLAY_SEEKING.state) {
g.setColor((musicPositionBarContains(displayContainer.mouseX, displayContainer.mouseY)) ? MUSICBAR_HOVER : MUSICBAR_NORMAL); g.setColor((musicPositionBarContains(mouseX, mouseY)) ? MUSICBAR_HOVER : MUSICBAR_NORMAL);
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4); g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
if (!isLeadIn()) { if (!isLeadIn()) {
g.setColor(MUSICBAR_FILL); g.setColor(MUSICBAR_FILL);
@ -721,7 +721,7 @@ public class Game extends ComplexOpsuState {
public void preRenderUpdate() { public void preRenderUpdate() {
super.preRenderUpdate(); super.preRenderUpdate();
int delta = displayContainer.renderDelta; int delta = renderDelta;
UI.update(delta); UI.update(delta);
Pippi.update(delta); Pippi.update(delta);
@ -729,8 +729,6 @@ public class Game extends ComplexOpsuState {
epiImgTime -= delta; epiImgTime -= delta;
} }
yugecin.opsudance.spinners.Spinner.update(delta); yugecin.opsudance.spinners.Spinner.update(delta);
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
skipButton.hoverUpdate(delta, mouseX, mouseY); skipButton.hoverUpdate(delta, mouseX, mouseY);
if (isReplay || GameMod.AUTO.isActive()) if (isReplay || GameMod.AUTO.isActive())
playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY); playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY);
@ -914,7 +912,7 @@ public class Game extends ComplexOpsuState {
} else if (GameMod.AUTOPILOT.isActive()) { } else if (GameMod.AUTOPILOT.isActive()) {
displayContainer.cursor.setCursorPosition(displayContainer.delta, (int) autoMousePosition.x, (int) autoMousePosition.y); displayContainer.cursor.setCursorPosition(displayContainer.delta, (int) autoMousePosition.x, (int) autoMousePosition.y);
} else { } else {
displayContainer.cursor.setCursorPosition(displayContainer.delta, displayContainer.mouseX, displayContainer.mouseY); displayContainer.cursor.setCursorPosition(displayContainer.delta, mouseX, mouseY);
} }
} }
@ -1104,8 +1102,6 @@ public class Game extends ComplexOpsuState {
} }
int trackPosition = MusicController.getPosition(); int trackPosition = MusicController.getPosition();
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
// game keys // game keys
if (!Keyboard.isRepeatEvent()) { if (!Keyboard.isRepeatEvent()) {
@ -1602,7 +1598,7 @@ public class Game extends ComplexOpsuState {
lastKeysPressed = ReplayFrame.KEY_NONE; lastKeysPressed = ReplayFrame.KEY_NONE;
replaySkipTime = -1; replaySkipTime = -1;
replayFrames = new LinkedList<>(); replayFrames = new LinkedList<>();
replayFrames.add(new ReplayFrame(0, 0, displayContainer.mouseX, displayContainer.mouseY, 0)); replayFrames.add(new ReplayFrame(0, 0, mouseX, mouseY, 0));
} }
for (int i = 0; i < gameObjects.length; i++) { for (int i = 0; i < gameObjects.length; i++) {

View File

@ -74,11 +74,11 @@ public class GamePauseMenu extends BaseOpsuState {
@Override @Override
public void preRenderUpdate() { public void preRenderUpdate() {
int delta = displayContainer.renderDelta; int delta = renderDelta;
UI.update(delta); UI.update(delta);
continueButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); continueButton.hoverUpdate(delta, mouseX, mouseY);
retryButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); retryButton.hoverUpdate(delta, mouseX, mouseY);
backButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); backButton.hoverUpdate(delta, mouseX, mouseY);
} }
@Override @Override
@ -90,9 +90,9 @@ public class GamePauseMenu extends BaseOpsuState {
// game keys // game keys
if (!Keyboard.isRepeatEvent()) { if (!Keyboard.isRepeatEvent()) {
if (key == OPTION_KEY_LEFT.intval) { if (key == OPTION_KEY_LEFT.intval) {
mousePressed(Input.MOUSE_LEFT_BUTTON, displayContainer.mouseX, displayContainer.mouseY); mousePressed(Input.MOUSE_LEFT_BUTTON, mouseX, mouseY);
} else if (key == OPTION_KEY_RIGHT.intval) { } else if (key == OPTION_KEY_RIGHT.intval) {
mousePressed(Input.MOUSE_RIGHT_BUTTON, displayContainer.mouseX, displayContainer.mouseY); mousePressed(Input.MOUSE_RIGHT_BUTTON, mouseX, mouseY);
} }
} }

View File

@ -99,15 +99,15 @@ public class GameRanking extends BaseOpsuState {
@Override @Override
public void preRenderUpdate() { public void preRenderUpdate() {
int delta = displayContainer.renderDelta; int delta = renderDelta;
UI.update(delta); UI.update(delta);
replayButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); replayButton.hoverUpdate(delta, mouseX, mouseY);
if (data.isGameplay()) { if (data.isGameplay()) {
retryButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); retryButton.hoverUpdate(delta, mouseX, mouseY);
} else { } else {
MusicController.loopTrackIfEnded(true); MusicController.loopTrackIfEnded(true);
} }
backButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY); backButton.hoverUpdate(delta, mouseX, mouseY);
} }
@Override @Override

View File

@ -407,8 +407,6 @@ public class MainMenu extends BaseOpsuState {
} }
// draw music position bar // draw music position bar
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL); g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL);
g.fillRect(this.musicBarX, this.musicBarY, this.musicBarWidth, this.musicBarHeight); g.fillRect(this.musicBarX, this.musicBarY, this.musicBarWidth, this.musicBarHeight);
g.setColor(Colors.WHITE_ALPHA_75); g.setColor(Colors.WHITE_ALPHA_75);
@ -471,7 +469,7 @@ public class MainMenu extends BaseOpsuState {
@Override @Override
public void preRenderUpdate() { public void preRenderUpdate() {
int delta = displayContainer.renderDelta; int delta = renderDelta;
final Iterator<PulseData> pulseDataIter = this.pulseData.iterator(); final Iterator<PulseData> pulseDataIter = this.pulseData.iterator();
while (pulseDataIter.hasNext()) { while (pulseDataIter.hasNext()) {
@ -485,8 +483,6 @@ public class MainMenu extends BaseOpsuState {
UI.update(delta); UI.update(delta);
if (MusicController.trackEnded()) if (MusicController.trackEnded())
nextTrack(false); // end of track: go to next track nextTrack(false); // end of track: go to next track
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
if (repoButton != null) { if (repoButton != null) {
repoButton.hoverUpdate(delta, mouseX, mouseY); repoButton.hoverUpdate(delta, mouseX, mouseY);
danceRepoButton.hoverUpdate(delta, mouseX, mouseY); danceRepoButton.hoverUpdate(delta, mouseX, mouseY);
@ -642,8 +638,6 @@ public class MainMenu extends BaseOpsuState {
starFountain.clear(); starFountain.clear();
// reset button hover states if mouse is not currently hovering over the button // reset button hover states if mouse is not currently hovering over the button
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
for (MenuButton b : this.musicButtons) { for (MenuButton b : this.musicButtons) {
if (!b.contains(mouseX, mouseY)) { if (!b.contains(mouseX, mouseY)) {
b.resetHover(); b.resetHover();

View File

@ -314,7 +314,7 @@ public class SongMenu extends ComplexOpsuState {
public SongMenu() { public SongMenu() {
super(); super();
optionsOverlay = new OptionsOverlay(displayContainer, OptionGroups.normalOptions); optionsOverlay = new OptionsOverlay(OptionGroups.normalOptions);
overlays.add(optionsOverlay); overlays.add(optionsOverlay);
} }
@ -343,7 +343,7 @@ public class SongMenu extends ComplexOpsuState {
int sortWidth = (int) (width * 0.12f); int sortWidth = (int) (width * 0.12f);
int posX = (int) (width * 0.87f); int posX = (int) (width * 0.87f);
int posY = (int) (headerY - GameImage.MENU_TAB.getImage().getHeight() * 2.25f); int posY = (int) (headerY - GameImage.MENU_TAB.getImage().getHeight() * 2.25f);
sortMenu = new DropdownMenu<BeatmapSortOrder>(displayContainer, BeatmapSortOrder.values(), posX, posY, sortWidth) { sortMenu = new DropdownMenu<BeatmapSortOrder>(BeatmapSortOrder.values(), posX, posY, sortWidth) {
@Override @Override
public void itemSelected(int index, BeatmapSortOrder item) { public void itemSelected(int index, BeatmapSortOrder item) {
BeatmapSortOrder.set(item); BeatmapSortOrder.set(item);
@ -459,9 +459,6 @@ public class SongMenu extends ComplexOpsuState {
public void render(Graphics g) { public void render(Graphics g) {
g.setBackground(Color.black); g.setBackground(Color.black);
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
// background // background
if (focusNode != null) { if (focusNode != null) {
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap(); Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
@ -708,7 +705,7 @@ public class SongMenu extends ComplexOpsuState {
public void preRenderUpdate() { public void preRenderUpdate() {
super.preRenderUpdate(); super.preRenderUpdate();
int delta = displayContainer.renderDelta; int delta = renderDelta;
UI.update(delta); UI.update(delta);
if (reloadThread == null) if (reloadThread == null)
MusicController.loopTrackIfEnded(true); MusicController.loopTrackIfEnded(true);
@ -724,8 +721,6 @@ public class SongMenu extends ComplexOpsuState {
MusicController.playThemeSong(config.themeBeatmap); MusicController.playThemeSong(config.themeBeatmap);
reloadThread = null; reloadThread = null;
} }
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
backButton.hoverUpdate(delta, mouseX, mouseY); backButton.hoverUpdate(delta, mouseX, mouseY);
selectModsButton.hoverUpdate(delta, mouseX, mouseY); selectModsButton.hoverUpdate(delta, mouseX, mouseY);
selectRandomButton.hoverUpdate(delta, mouseX, mouseY); selectRandomButton.hoverUpdate(delta, mouseX, mouseY);

View File

@ -30,6 +30,7 @@ import yugecin.opsudance.Dancer;
import yugecin.opsudance.skinning.SkinService; import yugecin.opsudance.skinning.SkinService;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/** /**
* Updates and draws the cursor. * Updates and draws the cursor.
@ -252,8 +253,8 @@ public class Cursor {
* If the old style cursor is being used, this will do nothing. * If the old style cursor is being used, this will do nothing.
* @param delta the delta interval since the last call * @param delta the delta interval since the last call
*/ */
public void updateAngle(int delta) { public void updateAngle() {
cursorAngle += delta / 40f; cursorAngle += renderDelta / 40f;
cursorAngle %= 360; cursorAngle %= 360;
} }

View File

@ -29,15 +29,14 @@ import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.UnicodeFont; import org.newdawn.slick.UnicodeFont;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.components.Component; import yugecin.opsudance.core.components.Component;
import static yugecin.opsudance.core.InstanceContainer.*;
public class DropdownMenu<E> extends Component { public class DropdownMenu<E> extends Component {
private static final float PADDING_Y = 0.1f, CHEVRON_X = 0.03f; private static final float PADDING_Y = 0.1f, CHEVRON_X = 0.03f;
private final DisplayContainer displayContainer;
private E[] items; private E[] items;
private String[] itemNames; private String[] itemNames;
private int selectedItemIndex; private int selectedItemIndex;
@ -61,8 +60,7 @@ public class DropdownMenu<E> extends Component {
private Image chevronDown; private Image chevronDown;
private Image chevronRight; private Image chevronRight;
public DropdownMenu(DisplayContainer displayContainer, E[] items, int x, int y, int width) { public DropdownMenu(E[] items, int x, int y, int width) {
this.displayContainer = displayContainer;
init(items, x, y, width); init(items, x, y, width);
} }
@ -143,13 +141,13 @@ public class DropdownMenu<E> extends Component {
@Override @Override
public void render(Graphics g) { public void render(Graphics g) {
int delta = displayContainer.renderDelta; int delta = renderDelta;
// update animation // update animation
expandProgress.update((expanded) ? delta : -delta * 2); expandProgress.update((expanded) ? delta : -delta * 2);
// get parameters // get parameters
int idx = getIndexAt(displayContainer.mouseY); int idx = getIndexAt(mouseY);
float t = expandProgress.getValue(); float t = expandProgress.getValue();
if (expanded) { if (expanded) {
t = AnimationEquation.OUT_CUBIC.calc(t); t = AnimationEquation.OUT_CUBIC.calc(t);
@ -245,7 +243,7 @@ public class DropdownMenu<E> extends Component {
return; return;
} }
int idx = getIndexAt(displayContainer.mouseY); int idx = getIndexAt(mouseY);
if (idx == -2) { if (idx == -2) {
this.expanded = false; this.expanded = false;
return; return;

View File

@ -279,8 +279,8 @@ public class UI {
textWidth += Fonts.SMALL.getWidth(tooltip); textWidth += Fonts.SMALL.getWidth(tooltip);
// get drawing coordinates // get drawing coordinates
int x = displayContainer.mouseX + offset; int x = mouseX + offset;
int y = displayContainer.mouseY + offset; int y = mouseY + offset;
if (x + textWidth > width - margin) if (x + textWidth > width - margin)
x = width - margin - textWidth; x = width - margin - textWidth;
else if (x < margin) else if (x < margin)

View File

@ -69,9 +69,6 @@ public class DisplayContainer implements ErrorDumpable, SkinChangedListener {
private Graphics graphics; private Graphics graphics;
public int mouseX;
public int mouseY;
private int targetUpdatesPerSecond; private int targetUpdatesPerSecond;
public int targetUpdateInterval; public int targetUpdateInterval;
private int targetRendersPerSecond; private int targetRendersPerSecond;
@ -79,7 +76,6 @@ public class DisplayContainer implements ErrorDumpable, SkinChangedListener {
public int targetBackgroundRenderInterval; public int targetBackgroundRenderInterval;
private boolean rendering; private boolean rendering;
public int renderDelta;
public int delta; public int delta;
public boolean exitRequested; public boolean exitRequested;
@ -230,7 +226,7 @@ public class DisplayContainer implements ErrorDumpable, SkinChangedListener {
bubNotifs.render(graphics); bubNotifs.render(graphics);
barNotifs.render(graphics); barNotifs.render(graphics);
cursor.updateAngle(renderDelta); cursor.updateAngle();
if (drawCursor) { if (drawCursor) {
cursor.draw(Mouse.isButtonDown(Input.MOUSE_LEFT_BUTTON) || cursor.draw(Mouse.isButtonDown(Input.MOUSE_LEFT_BUTTON) ||
Mouse.isButtonDown(Input.MOUSE_RIGHT_BUTTON)); Mouse.isButtonDown(Input.MOUSE_RIGHT_BUTTON));

View File

@ -76,6 +76,8 @@ public class InstanceContainer {
public static GamePauseMenu pauseState; public static GamePauseMenu pauseState;
public static int width, width2, height, height2; public static int width, width2, height, height2;
public static int mouseX, mouseY;
public static int renderDelta;
public static void kickstart() { public static void kickstart() {
updater = new Updater(); updater = new Updater();

View File

@ -130,7 +130,7 @@ public abstract class ComplexOpsuState extends BaseOpsuState {
public void preRenderUpdate() { public void preRenderUpdate() {
super.preRenderUpdate(); super.preRenderUpdate();
for (Component component : components) { for (Component component : components) {
component.updateHover(displayContainer.mouseX, displayContainer.mouseY); component.updateHover(mouseX, mouseY);
component.preRenderUpdate(); component.preRenderUpdate();
} }
for (OverlayOpsuState overlay : overlays) { for (OverlayOpsuState overlay : overlays) {

View File

@ -57,7 +57,7 @@ public class BarNotificationState implements ResolutionChangedListener {
if (timeShown >= TOTAL_TIME) { if (timeShown >= TOTAL_TIME) {
return; return;
} }
timeShown += displayContainer.renderDelta; timeShown += renderDelta;
processAnimations(); processAnimations();
g.setColor(bgcol); g.setColor(bgcol);
g.fillRect(0, height2 - barHalfHeight, width, barHalfHeight * 2); g.fillRect(0, height2 - barHalfHeight, width, barHalfHeight * 2);

View File

@ -53,7 +53,7 @@ public class BubNotifState implements MouseListener, ResolutionChangedListener {
if (!iter.hasNext()) { if (!iter.hasNext()) {
return; return;
} }
addAnimationTime += displayContainer.renderDelta; addAnimationTime += renderDelta;
if (addAnimationTime > IN_TIME) { if (addAnimationTime > IN_TIME) {
finishAddAnimation(); finishAddAnimation();
} }
@ -63,7 +63,7 @@ public class BubNotifState implements MouseListener, ResolutionChangedListener {
if (animateUp && addAnimationTime < IN_TIME) { if (animateUp && addAnimationTime < IN_TIME) {
next.y = next.baseY - (int) (addAnimationHeight * AnimationEquation.OUT_QUINT.calc((float) addAnimationTime / IN_TIME)); next.y = next.baseY - (int) (addAnimationHeight * AnimationEquation.OUT_QUINT.calc((float) addAnimationTime / IN_TIME));
} }
if (next.render(g, displayContainer.mouseX, displayContainer.mouseY, displayContainer.renderDelta)) { if (next.render(g, mouseX, mouseY, renderDelta)) {
iter.remove(); iter.remove();
} }
animateUp = true; animateUp = true;

View File

@ -49,7 +49,7 @@ public class FpsRenderState implements ResolutionChangedListener {
} }
public void render(Graphics g) { public void render(Graphics g) {
fpsMeter.update(displayContainer.renderDelta); fpsMeter.update(renderDelta);
if (!OPTION_SHOW_FPS.state) { if (!OPTION_SHOW_FPS.state) {
return; return;
} }

View File

@ -23,7 +23,6 @@ import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.animations.AnimationEquation; import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.OverlayOpsuState; import yugecin.opsudance.core.state.OverlayOpsuState;
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover; import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
import yugecin.opsudance.sbv2.movers.LinearStoryboardMover; import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
@ -38,8 +37,6 @@ import static yugecin.opsudance.core.InstanceContainer.*;
public class MoveStoryboard extends OverlayOpsuState{ public class MoveStoryboard extends OverlayOpsuState{
private final DisplayContainer displayContainer;
private SimpleButton btnAddLinear; private SimpleButton btnAddLinear;
private SimpleButton btnAddQuadratic; private SimpleButton btnAddQuadratic;
private SimpleButton btnAddCubic; private SimpleButton btnAddCubic;
@ -57,8 +54,7 @@ public class MoveStoryboard extends OverlayOpsuState{
private int trackPosition; private int trackPosition;
public MoveStoryboard(DisplayContainer displayContainer) { public MoveStoryboard() {
this.displayContainer = displayContainer;
dummyMove = (StoryboardMove) Proxy.newProxyInstance(StoryboardMove.class.getClassLoader(), new Class<?>[]{StoryboardMove.class}, new InvocationHandler() { dummyMove = (StoryboardMove) Proxy.newProxyInstance(StoryboardMove.class.getClassLoader(), new Class<?>[]{StoryboardMove.class}, new InvocationHandler() {
@Override @Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@ -98,8 +94,8 @@ public class MoveStoryboard extends OverlayOpsuState{
@Override @Override
protected void onPreRenderUpdate() { protected void onPreRenderUpdate() {
int x = displayContainer.mouseX; int x = mouseX;
int y = displayContainer.mouseY; int y = mouseY;
btnAddLinear.update(x, y); btnAddLinear.update(x, y);
btnAddQuadratic.update(x, y); btnAddQuadratic.update(x, y);
btnAddCubic.update(x, y); btnAddCubic.update(x, y);
@ -107,7 +103,7 @@ public class MoveStoryboard extends OverlayOpsuState{
btnAnimMid.update(x, y); btnAnimMid.update(x, y);
btnAnimCub.update(x, y); btnAnimCub.update(x, y);
if (moves[objectIndex] != null) { if (moves[objectIndex] != null) {
moves[objectIndex].update(displayContainer.renderDelta, x, y); moves[objectIndex].update(renderDelta, x, y);
} }
} }

View File

@ -26,7 +26,6 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.newdawn.slick.*; import org.newdawn.slick.*;
import org.newdawn.slick.gui.TextField; import org.newdawn.slick.gui.TextField;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.OverlayOpsuState; import yugecin.opsudance.core.state.OverlayOpsuState;
import yugecin.opsudance.options.*; import yugecin.opsudance.options.*;
import yugecin.opsudance.utils.FontUtil; import yugecin.opsudance.utils.FontUtil;
@ -40,8 +39,6 @@ import static yugecin.opsudance.options.Options.*;
public class OptionsOverlay extends OverlayOpsuState { public class OptionsOverlay extends OverlayOpsuState {
private final DisplayContainer displayContainer;
private static final float BG_ALPHA = 0.7f; private static final float BG_ALPHA = 0.7f;
private static final float LINEALPHA = 0.8f; private static final float LINEALPHA = 0.8f;
private static final Color COL_BG = new Color(Color.black); private static final Color COL_BG = new Color(Color.black);
@ -161,9 +158,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private int invalidSearchAnimationProgress; private int invalidSearchAnimationProgress;
private final int INVALID_SEARCH_ANIMATION_TIME = 500; private final int INVALID_SEARCH_ANIMATION_TIME = 500;
public OptionsOverlay(DisplayContainer displayContainer, OptionTab[] sections) { public OptionsOverlay(OptionTab[] sections) {
this.displayContainer = displayContainer;
this.sections = sections; this.sections = sections;
dropdownMenus = new HashMap<>(); dropdownMenus = new HashMap<>();
@ -231,7 +226,7 @@ public class OptionsOverlay extends OverlayOpsuState {
} }
final ListOption listOption = (ListOption) option; final ListOption listOption = (ListOption) option;
Object[] items = listOption.getListItems(); Object[] items = listOption.getListItems();
DropdownMenu<Object> menu = new DropdownMenu<Object>(displayContainer, items, 0, 0, 0) { DropdownMenu<Object> menu = new DropdownMenu<Object>(items, 0, 0, 0) {
@Override @Override
public void itemSelected(int index, Object item) { public void itemSelected(int index, Object item) {
listOption.clickListItem(index); listOption.clickListItem(index);
@ -313,7 +308,7 @@ public class OptionsOverlay extends OverlayOpsuState {
navWidth += navTargetWidth; navWidth += navTargetWidth;
} else if (navHoverTime > 300) { } else if (navHoverTime > 300) {
AnimationEquation anim = AnimationEquation.IN_EXPO; AnimationEquation anim = AnimationEquation.IN_EXPO;
if (displayContainer.mouseX < navWidth) { if (mouseX < navWidth) {
anim = AnimationEquation.OUT_EXPO; anim = AnimationEquation.OUT_EXPO;
} }
float progress = anim.calc((navHoverTime - 300f) / 300f); float progress = anim.calc((navHoverTime - 300f) / 300f);
@ -362,7 +357,7 @@ public class OptionsOverlay extends OverlayOpsuState {
g.setColor(COL_INDICATOR); g.setColor(COL_INDICATOR);
int indicatorPos = this.indicatorPos; int indicatorPos = this.indicatorPos;
if (indicatorMoveAnimationTime > 0) { if (indicatorMoveAnimationTime > 0) {
indicatorMoveAnimationTime += displayContainer.renderDelta; indicatorMoveAnimationTime += renderDelta;
if (indicatorMoveAnimationTime > INDICATORMOVEANIMATIONTIME) { if (indicatorMoveAnimationTime > INDICATORMOVEANIMATIONTIME) {
indicatorMoveAnimationTime = 0; indicatorMoveAnimationTime = 0;
indicatorPos += indicatorOffsetToNextPos; indicatorPos += indicatorOffsetToNextPos;
@ -390,7 +385,7 @@ public class OptionsOverlay extends OverlayOpsuState {
if (hoverOption instanceof NumericOption) { if (hoverOption instanceof NumericOption) {
tip = "(" + hoverOption.getValueString() + ") " + tip; tip = "(" + hoverOption.getValueString() + ") " + tip;
} }
UI.updateTooltip(displayContainer.renderDelta, tip, true); UI.updateTooltip(renderDelta, tip, true);
UI.drawTooltip(g); UI.drawTooltip(g);
} }
} }
@ -634,9 +629,7 @@ public class OptionsOverlay extends OverlayOpsuState {
@Override @Override
public void onPreRenderUpdate() { public void onPreRenderUpdate() {
int mouseX = displayContainer.mouseX; int delta = renderDelta;
int mouseY = displayContainer.mouseY;
int delta = displayContainer.renderDelta;
int prevscrollpos = scrollHandler.getIntPosition(); int prevscrollpos = scrollHandler.getIntPosition();
scrollHandler.update(delta); scrollHandler.update(delta);
@ -715,7 +708,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private void updateIndicatorAlpha() { private void updateIndicatorAlpha() {
if (hoverOption == null) { if (hoverOption == null) {
if (indicatorHideAnimationTime < INDICATORHIDEANIMATIONTIME) { if (indicatorHideAnimationTime < INDICATORHIDEANIMATIONTIME) {
indicatorHideAnimationTime += displayContainer.renderDelta; indicatorHideAnimationTime += renderDelta;
if (indicatorHideAnimationTime > INDICATORHIDEANIMATIONTIME) { if (indicatorHideAnimationTime > INDICATORHIDEANIMATIONTIME) {
indicatorHideAnimationTime = INDICATORHIDEANIMATIONTIME; indicatorHideAnimationTime = INDICATORHIDEANIMATIONTIME;
} }
@ -724,7 +717,7 @@ public class OptionsOverlay extends OverlayOpsuState {
COL_INDICATOR.a = (1f - progress) * INDICATOR_ALPHA * showHideProgress; COL_INDICATOR.a = (1f - progress) * INDICATOR_ALPHA * showHideProgress;
} }
} else if (indicatorHideAnimationTime > 0) { } else if (indicatorHideAnimationTime > 0) {
indicatorHideAnimationTime -= displayContainer.renderDelta * 3; indicatorHideAnimationTime -= renderDelta * 3;
if (indicatorHideAnimationTime < 0) { if (indicatorHideAnimationTime < 0) {
indicatorHideAnimationTime = 0; indicatorHideAnimationTime = 0;
} }
@ -967,7 +960,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private void updateSliderOption() { private void updateSliderOption() {
NumericOption o = (NumericOption) hoverOption; NumericOption o = (NumericOption) hoverOption;
int value = o.min + Math.round((float) (o.max - o.min) * (displayContainer.mouseX - sliderOptionStartX) / (sliderOptionLength)); int value = o.min + Math.round((float) (o.max - o.min) * (mouseX - sliderOptionStartX) / (sliderOptionLength));
o.setValue(Utils.clamp(value, o.min, o.max)); o.setValue(Utils.clamp(value, o.min, o.max));
} }