more easier access to common variables
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user