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 followAlpha = 1f;
if (followCircleActive && followExpandTime < FOLLOW_EXPAND_TIME) {
followExpandTime += displayContainer.renderDelta;
followExpandTime += renderDelta;
followCircleScale *= 0.5f;
float progress = AnimationEquation.OUT_QUAD.calc((float) followExpandTime / FOLLOW_EXPAND_TIME);
followCircleScale = followCircleScale + followCircleScale * progress;
followAlpha = progress;
} else if (!followCircleActive) {
followExpandTime -= displayContainer.renderDelta;
followExpandTime -= renderDelta;
if (followExpandTime > FOLLOW_SHRINK_TIME) {
followExpandTime = FOLLOW_SHRINK_TIME;
}

View File

@ -226,14 +226,14 @@ public class ButtonMenu extends BaseOpsuState {
super.preRenderUpdate();
GameMod hoverMod = null;
for (GameMod mod : GameMod.values()) {
mod.hoverUpdate(displayContainer.renderDelta, mod.isActive());
if (hoverMod == null && mod.contains(displayContainer.mouseX, displayContainer.mouseY))
mod.hoverUpdate(renderDelta, mod.isActive());
if (hoverMod == null && mod.contains(mouseX, mouseY))
hoverMod = mod;
}
// tooltips
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.
*/
public void preRenderUpdate() {
boolean centerOffsetUpdated = centerOffset.update(displayContainer.renderDelta);
boolean centerOffsetUpdated = centerOffset.update(renderDelta);
float centerOffsetX = centerOffset.getValue();
final float[] offsets = { centerOffsetX, - centerOffsetX };
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
if (centerOffsetUpdated) {
@ -622,7 +622,7 @@ public class ButtonMenu extends BaseOpsuState {
public void preRenderUpdate() {
super.preRenderUpdate();
UI.update(displayContainer.renderDelta);
UI.update(renderDelta);
MusicController.loopTrackIfEnded(false);
menuState.preRenderUpdate();
}

View File

@ -364,7 +364,7 @@ public class DownloadsMenu extends ComplexOpsuState {
// dropdown menu
int serverWidth = (int) (width * 0.12f);
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
public void itemSelected(int index, DownloadServer item) {
resultList = null;
@ -433,7 +433,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (index >= nodes.length)
break;
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()));
}
g.clearClip();
@ -479,7 +479,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (node == null)
break;
node.drawDownload(g, i * DownloadNode.getInfoHeight() + offset, index,
DownloadNode.downloadContains(displayContainer.mouseX, displayContainer.mouseY - offset, i));
DownloadNode.downloadContains(mouseX, mouseY - offset, i));
}
g.clearClip();
@ -516,7 +516,7 @@ public class DownloadsMenu extends ComplexOpsuState {
public void preRenderUpdate() {
super.preRenderUpdate();
int delta = displayContainer.renderDelta;
int delta = renderDelta;
UI.update(delta);
if (importThread == null)
MusicController.loopTrackIfEnded(false);
@ -537,8 +537,6 @@ public class DownloadsMenu extends ComplexOpsuState {
}
importThread = null;
}
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
backButton.hoverUpdate(delta, mouseX, mouseY);
prevPage.hoverUpdate(delta, mouseX, mouseY);
nextPage.hoverUpdate(delta, mouseX, mouseY);
@ -846,7 +844,7 @@ public class DownloadsMenu extends ComplexOpsuState {
}
int shift = (newValue < 0) ? 1 : -1;
scrollLists(displayContainer.mouseX, displayContainer.mouseY, shift);
scrollLists(mouseX, mouseY, shift);
return true;
}

View File

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

View File

@ -74,11 +74,11 @@ public class GamePauseMenu extends BaseOpsuState {
@Override
public void preRenderUpdate() {
int delta = displayContainer.renderDelta;
int delta = renderDelta;
UI.update(delta);
continueButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
retryButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
backButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
continueButton.hoverUpdate(delta, mouseX, mouseY);
retryButton.hoverUpdate(delta, mouseX, mouseY);
backButton.hoverUpdate(delta, mouseX, mouseY);
}
@Override
@ -90,9 +90,9 @@ public class GamePauseMenu extends BaseOpsuState {
// game keys
if (!Keyboard.isRepeatEvent()) {
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) {
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
public void preRenderUpdate() {
int delta = displayContainer.renderDelta;
int delta = renderDelta;
UI.update(delta);
replayButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
replayButton.hoverUpdate(delta, mouseX, mouseY);
if (data.isGameplay()) {
retryButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
retryButton.hoverUpdate(delta, mouseX, mouseY);
} else {
MusicController.loopTrackIfEnded(true);
}
backButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
backButton.hoverUpdate(delta, mouseX, mouseY);
}
@Override

View File

@ -407,8 +407,6 @@ public class MainMenu extends BaseOpsuState {
}
// 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.fillRect(this.musicBarX, this.musicBarY, this.musicBarWidth, this.musicBarHeight);
g.setColor(Colors.WHITE_ALPHA_75);
@ -471,7 +469,7 @@ public class MainMenu extends BaseOpsuState {
@Override
public void preRenderUpdate() {
int delta = displayContainer.renderDelta;
int delta = renderDelta;
final Iterator<PulseData> pulseDataIter = this.pulseData.iterator();
while (pulseDataIter.hasNext()) {
@ -485,8 +483,6 @@ public class MainMenu extends BaseOpsuState {
UI.update(delta);
if (MusicController.trackEnded())
nextTrack(false); // end of track: go to next track
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
if (repoButton != null) {
repoButton.hoverUpdate(delta, mouseX, mouseY);
danceRepoButton.hoverUpdate(delta, mouseX, mouseY);
@ -642,8 +638,6 @@ public class MainMenu extends BaseOpsuState {
starFountain.clear();
// 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) {
if (!b.contains(mouseX, mouseY)) {
b.resetHover();

View File

@ -314,7 +314,7 @@ public class SongMenu extends ComplexOpsuState {
public SongMenu() {
super();
optionsOverlay = new OptionsOverlay(displayContainer, OptionGroups.normalOptions);
optionsOverlay = new OptionsOverlay(OptionGroups.normalOptions);
overlays.add(optionsOverlay);
}
@ -343,7 +343,7 @@ public class SongMenu extends ComplexOpsuState {
int sortWidth = (int) (width * 0.12f);
int posX = (int) (width * 0.87f);
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
public void itemSelected(int index, BeatmapSortOrder item) {
BeatmapSortOrder.set(item);
@ -459,9 +459,6 @@ public class SongMenu extends ComplexOpsuState {
public void render(Graphics g) {
g.setBackground(Color.black);
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
// background
if (focusNode != null) {
Beatmap focusNodeBeatmap = focusNode.getSelectedBeatmap();
@ -708,7 +705,7 @@ public class SongMenu extends ComplexOpsuState {
public void preRenderUpdate() {
super.preRenderUpdate();
int delta = displayContainer.renderDelta;
int delta = renderDelta;
UI.update(delta);
if (reloadThread == null)
MusicController.loopTrackIfEnded(true);
@ -724,8 +721,6 @@ public class SongMenu extends ComplexOpsuState {
MusicController.playThemeSong(config.themeBeatmap);
reloadThread = null;
}
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
backButton.hoverUpdate(delta, mouseX, mouseY);
selectModsButton.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 static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* Updates and draws the cursor.
@ -252,8 +253,8 @@ public class Cursor {
* If the old style cursor is being used, this will do nothing.
* @param delta the delta interval since the last call
*/
public void updateAngle(int delta) {
cursorAngle += delta / 40f;
public void updateAngle() {
cursorAngle += renderDelta / 40f;
cursorAngle %= 360;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -53,7 +53,7 @@ public class BubNotifState implements MouseListener, ResolutionChangedListener {
if (!iter.hasNext()) {
return;
}
addAnimationTime += displayContainer.renderDelta;
addAnimationTime += renderDelta;
if (addAnimationTime > IN_TIME) {
finishAddAnimation();
}
@ -63,7 +63,7 @@ public class BubNotifState implements MouseListener, ResolutionChangedListener {
if (animateUp && 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();
}
animateUp = true;

View File

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

View File

@ -23,7 +23,6 @@ import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.OverlayOpsuState;
import yugecin.opsudance.sbv2.movers.CubicStoryboardMover;
import yugecin.opsudance.sbv2.movers.LinearStoryboardMover;
@ -38,8 +37,6 @@ import static yugecin.opsudance.core.InstanceContainer.*;
public class MoveStoryboard extends OverlayOpsuState{
private final DisplayContainer displayContainer;
private SimpleButton btnAddLinear;
private SimpleButton btnAddQuadratic;
private SimpleButton btnAddCubic;
@ -57,8 +54,7 @@ public class MoveStoryboard extends OverlayOpsuState{
private int trackPosition;
public MoveStoryboard(DisplayContainer displayContainer) {
this.displayContainer = displayContainer;
public MoveStoryboard() {
dummyMove = (StoryboardMove) Proxy.newProxyInstance(StoryboardMove.class.getClassLoader(), new Class<?>[]{StoryboardMove.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@ -98,8 +94,8 @@ public class MoveStoryboard extends OverlayOpsuState{
@Override
protected void onPreRenderUpdate() {
int x = displayContainer.mouseX;
int y = displayContainer.mouseY;
int x = mouseX;
int y = mouseY;
btnAddLinear.update(x, y);
btnAddQuadratic.update(x, y);
btnAddCubic.update(x, y);
@ -107,7 +103,7 @@ public class MoveStoryboard extends OverlayOpsuState{
btnAnimMid.update(x, y);
btnAnimCub.update(x, y);
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.newdawn.slick.*;
import org.newdawn.slick.gui.TextField;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.OverlayOpsuState;
import yugecin.opsudance.options.*;
import yugecin.opsudance.utils.FontUtil;
@ -40,8 +39,6 @@ import static yugecin.opsudance.options.Options.*;
public class OptionsOverlay extends OverlayOpsuState {
private final DisplayContainer displayContainer;
private static final float BG_ALPHA = 0.7f;
private static final float LINEALPHA = 0.8f;
private static final Color COL_BG = new Color(Color.black);
@ -161,9 +158,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private int invalidSearchAnimationProgress;
private final int INVALID_SEARCH_ANIMATION_TIME = 500;
public OptionsOverlay(DisplayContainer displayContainer, OptionTab[] sections) {
this.displayContainer = displayContainer;
public OptionsOverlay(OptionTab[] sections) {
this.sections = sections;
dropdownMenus = new HashMap<>();
@ -231,7 +226,7 @@ public class OptionsOverlay extends OverlayOpsuState {
}
final ListOption listOption = (ListOption) option;
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
public void itemSelected(int index, Object item) {
listOption.clickListItem(index);
@ -313,7 +308,7 @@ public class OptionsOverlay extends OverlayOpsuState {
navWidth += navTargetWidth;
} else if (navHoverTime > 300) {
AnimationEquation anim = AnimationEquation.IN_EXPO;
if (displayContainer.mouseX < navWidth) {
if (mouseX < navWidth) {
anim = AnimationEquation.OUT_EXPO;
}
float progress = anim.calc((navHoverTime - 300f) / 300f);
@ -362,7 +357,7 @@ public class OptionsOverlay extends OverlayOpsuState {
g.setColor(COL_INDICATOR);
int indicatorPos = this.indicatorPos;
if (indicatorMoveAnimationTime > 0) {
indicatorMoveAnimationTime += displayContainer.renderDelta;
indicatorMoveAnimationTime += renderDelta;
if (indicatorMoveAnimationTime > INDICATORMOVEANIMATIONTIME) {
indicatorMoveAnimationTime = 0;
indicatorPos += indicatorOffsetToNextPos;
@ -390,7 +385,7 @@ public class OptionsOverlay extends OverlayOpsuState {
if (hoverOption instanceof NumericOption) {
tip = "(" + hoverOption.getValueString() + ") " + tip;
}
UI.updateTooltip(displayContainer.renderDelta, tip, true);
UI.updateTooltip(renderDelta, tip, true);
UI.drawTooltip(g);
}
}
@ -634,9 +629,7 @@ public class OptionsOverlay extends OverlayOpsuState {
@Override
public void onPreRenderUpdate() {
int mouseX = displayContainer.mouseX;
int mouseY = displayContainer.mouseY;
int delta = displayContainer.renderDelta;
int delta = renderDelta;
int prevscrollpos = scrollHandler.getIntPosition();
scrollHandler.update(delta);
@ -715,7 +708,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private void updateIndicatorAlpha() {
if (hoverOption == null) {
if (indicatorHideAnimationTime < INDICATORHIDEANIMATIONTIME) {
indicatorHideAnimationTime += displayContainer.renderDelta;
indicatorHideAnimationTime += renderDelta;
if (indicatorHideAnimationTime > INDICATORHIDEANIMATIONTIME) {
indicatorHideAnimationTime = INDICATORHIDEANIMATIONTIME;
}
@ -724,7 +717,7 @@ public class OptionsOverlay extends OverlayOpsuState {
COL_INDICATOR.a = (1f - progress) * INDICATOR_ALPHA * showHideProgress;
}
} else if (indicatorHideAnimationTime > 0) {
indicatorHideAnimationTime -= displayContainer.renderDelta * 3;
indicatorHideAnimationTime -= renderDelta * 3;
if (indicatorHideAnimationTime < 0) {
indicatorHideAnimationTime = 0;
}
@ -967,7 +960,7 @@ public class OptionsOverlay extends OverlayOpsuState {
private void updateSliderOption() {
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));
}