simplify access to display width and height and halves
This commit is contained in:
@@ -603,8 +603,6 @@ public class GameData {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void drawGameElements(Graphics g, boolean breakPeriod, boolean firstObject, float alpha) {
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
boolean relaxAutoPilot = (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive());
|
||||
int margin = (int) (width * 0.008f);
|
||||
float uiScale = GameImage.getUIscale();
|
||||
@@ -796,9 +794,6 @@ public class GameData {
|
||||
* @param beatmap the beatmap
|
||||
*/
|
||||
public void drawRankingElements(Graphics g, Beatmap beatmap) {
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
|
||||
// TODO Version 2 skins
|
||||
float rankingHeight = 75;
|
||||
float scoreTextScale = 1.0f;
|
||||
@@ -911,7 +906,7 @@ public class GameData {
|
||||
if (hitResult.hitResultType == HitObjectType.SPINNER && hitResult.result != HIT_MISS) {
|
||||
Image spinnerOsu = GameImage.SPINNER_OSU.getImage();
|
||||
spinnerOsu.setAlpha(hitResult.alpha);
|
||||
spinnerOsu.drawCentered(displayContainer.width / 2, displayContainer.height / 4);
|
||||
spinnerOsu.drawCentered(width2, height / 4);
|
||||
spinnerOsu.setAlpha(1f);
|
||||
} else if (OPTION_SHOW_HIT_LIGHTING.state && !hitResult.hideResult && hitResult.result != HIT_MISS &&
|
||||
// hit lighting
|
||||
@@ -1185,7 +1180,7 @@ public class GameData {
|
||||
// combo burst
|
||||
if (comboBurstIndex > -1 && OPTION_SHOW_COMBO_BURSTS.state) {
|
||||
int leftX = 0;
|
||||
int rightX = displayContainer.width - comboBurstImages[comboBurstIndex].getWidth();
|
||||
int rightX = width - comboBurstImages[comboBurstIndex].getWidth();
|
||||
if (comboBurstX < leftX) {
|
||||
comboBurstX += (delta / 2f) * GameImage.getUIscale();
|
||||
if (comboBurstX > leftX)
|
||||
@@ -1246,7 +1241,7 @@ public class GameData {
|
||||
}
|
||||
comboBurstAlpha = 0.8f;
|
||||
if ((comboBurstIndex % 2) == 0) {
|
||||
comboBurstX = displayContainer.width;
|
||||
comboBurstX = width;
|
||||
} else {
|
||||
comboBurstX = comboBurstImages[0].getWidth() * -1;
|
||||
}
|
||||
|
||||
@@ -464,8 +464,8 @@ public class Utils {
|
||||
*/
|
||||
public static int getRegion(double x, double y) {
|
||||
int q = 0;
|
||||
if (y < displayContainer.height / 2d) q = 2;
|
||||
if (x < displayContainer.width / 2d) q |= 1;
|
||||
if (y < height2) q = 2;
|
||||
if (x < width2) q |= 1;
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -483,24 +483,24 @@ public class Utils {
|
||||
*/
|
||||
|
||||
public static float[] mirrorPoint(float x, float y) {
|
||||
double dx = x - displayContainer.width / 2d;
|
||||
double dy = y - displayContainer.height / 2d;
|
||||
double dx = x - width2;
|
||||
double dy = y - height2;
|
||||
double ang = Math.atan2(dy, dx);
|
||||
double d = -Math.sqrt(dx * dx + dy * dy);
|
||||
return new float[]{
|
||||
(float) (displayContainer.width / 2d + Math.cos(ang) * d),
|
||||
(float) (displayContainer.height / 2d + Math.sin(ang) * d)
|
||||
(float) (width2 + Math.cos(ang) * d),
|
||||
(float) (height2 + Math.sin(ang) * d)
|
||||
};
|
||||
}
|
||||
|
||||
public static float[] mirrorPoint(float x, float y, float degrees) {
|
||||
double dx = x - displayContainer.width / 2d;
|
||||
double dy = y - displayContainer.height / 2d;
|
||||
double dx = x - width2;
|
||||
double dy = y - height2;
|
||||
double ang = Math.atan2(dy, dx) + (degrees * Math.PI / 180d);
|
||||
double d = Math.sqrt(dx * dx + dy * dy);
|
||||
return new float[]{
|
||||
(float) (displayContainer.width / 2d + Math.cos(ang) * d),
|
||||
(float) (displayContainer.height / 2d + Math.sin(ang) * d)
|
||||
(float) (width2 + Math.cos(ang) * d),
|
||||
(float) (height2 + Math.sin(ang) * d)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ public class Slider extends GameObject {
|
||||
float oldAlphaBlack = Colors.BLACK_ALPHA.a;
|
||||
Colors.BLACK_ALPHA.a = 0.75f;
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, displayContainer.width, displayContainer.height);
|
||||
g.fillRect(0, 0, width, height);
|
||||
Colors.BLACK_ALPHA.a = oldAlphaBlack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,14 @@ import itdelatrisu.opsu.ui.Colors;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.skinning.SkinService;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* Data type representing a spinner object.
|
||||
*/
|
||||
public class Spinner extends GameObject {
|
||||
/** Container dimensions. */
|
||||
private static int width, height;
|
||||
|
||||
/** The map's overall difficulty value. */
|
||||
private static float overallDifficulty = 5f;
|
||||
@@ -111,9 +110,7 @@ public class Spinner extends GameObject {
|
||||
* Initializes the Spinner data type with images and dimensions.
|
||||
* @param difficulty the map's overall difficulty value
|
||||
*/
|
||||
public static void init(DisplayContainer displayContainer, float difficulty) {
|
||||
width = displayContainer.width;
|
||||
height = displayContainer.height;
|
||||
public static void init(float difficulty) {
|
||||
overallDifficulty = difficulty;
|
||||
}
|
||||
|
||||
@@ -200,7 +197,7 @@ public class Spinner extends GameObject {
|
||||
// rpm
|
||||
Image rpmImg = GameImage.SPINNER_RPM.getImage();
|
||||
rpmImg.setAlpha(alpha);
|
||||
rpmImg.drawCentered(width / 2f, height - rpmImg.getHeight() / 2f);
|
||||
rpmImg.drawCentered(width2, height - rpmImg.getHeight() / 2f);
|
||||
if (timeDiff < 0)
|
||||
data.drawSymbolString(Integer.toString(drawnRPM), (width + rpmImg.getWidth() * 0.95f) / 2f,
|
||||
height - data.getScoreSymbolImage('0').getHeight() * 1.025f, 1f, 1f, true);
|
||||
@@ -218,21 +215,21 @@ public class Spinner extends GameObject {
|
||||
// main spinner elements
|
||||
GameImage.SPINNER_CIRCLE.getImage().setAlpha(alpha);
|
||||
GameImage.SPINNER_CIRCLE.getImage().setRotation(drawRotation * 360f);
|
||||
GameImage.SPINNER_CIRCLE.getImage().drawCentered(width / 2, height / 2);
|
||||
GameImage.SPINNER_CIRCLE.getImage().drawCentered(width2, height2);
|
||||
if (!GameMod.HIDDEN.isActive()) {
|
||||
float approachScale = 1 - Utils.clamp(((float) timeDiff / (hitObject.getTime() - hitObject.getEndTime())), 0f, 1f);
|
||||
Image approachCircleScaled = GameImage.SPINNER_APPROACHCIRCLE.getImage().getScaledCopy(approachScale);
|
||||
approachCircleScaled.setAlpha(alpha);
|
||||
approachCircleScaled.drawCentered(width / 2, height / 2);
|
||||
approachCircleScaled.drawCentered(width2, height2);
|
||||
}
|
||||
GameImage.SPINNER_SPIN.getImage().setAlpha(alpha);
|
||||
GameImage.SPINNER_SPIN.getImage().drawCentered(width / 2, height * 3 / 4);
|
||||
GameImage.SPINNER_SPIN.getImage().drawCentered(width2, height * 3 / 4);
|
||||
|
||||
if (spinnerComplete) {
|
||||
GameImage.SPINNER_CLEAR.getImage().drawCentered(width / 2, height / 4);
|
||||
GameImage.SPINNER_CLEAR.getImage().drawCentered(width2, height / 4);
|
||||
int extraRotations = (int) (rotations - rotationsNeeded);
|
||||
if (extraRotations > 0)
|
||||
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1f, 1f);
|
||||
data.drawSymbolNumber(extraRotations * 1000, width2, height * 2 / 3, 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,14 +251,14 @@ public class Spinner extends GameObject {
|
||||
else
|
||||
result = GameData.HIT_MISS;
|
||||
|
||||
data.sendHitResult(hitObject.getEndTime(), result, width / 2, height / 2,
|
||||
data.sendHitResult(hitObject.getEndTime(), result, width2, height2,
|
||||
Color.transparent, true, hitObject, HitObjectType.SPINNER, true, 0, null, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int x, int y, int trackPosition) {
|
||||
lastAngle = (float) Math.atan2(x - (height / 2), y - (width / 2));
|
||||
lastAngle = (float) Math.atan2(x - height2, y - width2);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -290,7 +287,7 @@ public class Spinner extends GameObject {
|
||||
angleDiff = delta * SPUN_OUT_MULTIPLIER;
|
||||
isSpinning = true;
|
||||
} else {
|
||||
float angle = (float) Math.atan2(mouseY - (height / 2), mouseX - (width / 2));
|
||||
float angle = (float) Math.atan2(mouseY - height2, mouseX - width2);
|
||||
|
||||
// set initial angle to current mouse position to skip first click
|
||||
if (!isSpinning && (keyPressed || GameMod.RELAX.isActive())) {
|
||||
|
||||
@@ -98,13 +98,13 @@ public abstract class Curve {
|
||||
* @param circleDiameter the circle diameter
|
||||
* @param borderColor the curve border color
|
||||
*/
|
||||
public static void init(int width, int height, float circleDiameter, Color borderColor) {
|
||||
public static void init(float circleDiameter, Color borderColor) {
|
||||
Curve.borderColor = borderColor;
|
||||
|
||||
ContextCapabilities capabilities = GLContext.getCapabilities();
|
||||
mmsliderSupported = capabilities.OpenGL30;
|
||||
if (mmsliderSupported) {
|
||||
CurveRenderState.init(width, height, circleDiameter);
|
||||
CurveRenderState.init(circleDiameter);
|
||||
} else if (SkinService.skin.getSliderStyle() != Skin.STYLE_PEPPYSLIDER) {
|
||||
Log.warn("New slider style requires OpenGL 3.0.");
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ import static yugecin.opsudance.options.Options.*;
|
||||
* @author Bigpet {@literal <dravorek (at) gmail.com>}
|
||||
*/
|
||||
public class CurveRenderState {
|
||||
/** The width and height of the display container this curve gets drawn into. */
|
||||
protected static int containerWidth, containerHeight;
|
||||
|
||||
/** Thickness of the curve. */
|
||||
protected static int scale;
|
||||
@@ -83,10 +81,7 @@ public class CurveRenderState {
|
||||
* @param height the container height
|
||||
* @param circleDiameter the circle diameter
|
||||
*/
|
||||
public static void init(int width, int height, float circleDiameter) {
|
||||
containerWidth = width;
|
||||
containerHeight = height;
|
||||
|
||||
public static void init(float circleDiameter) {
|
||||
// equivalent to what happens in Slider.init()
|
||||
scale = (int) (circleDiameter * HitObject.getXMultiplier()); // convert from Osupixels (640x480)
|
||||
//scale = scale * 118 / 128; //for curves exactly as big as the sliderball
|
||||
@@ -410,8 +405,6 @@ public class CurveRenderState {
|
||||
x1 = m[0];
|
||||
y1 = m[1];
|
||||
}
|
||||
float divx = containerWidth / 2.0f;
|
||||
float divy = containerHeight / 2.0f;
|
||||
float offx = -1.0f;
|
||||
float offy = 1.0f;
|
||||
float radius = scale / 2;
|
||||
@@ -419,8 +412,8 @@ public class CurveRenderState {
|
||||
for (int i = 0; i < NewCurveStyleState.unitCone.length / 6; ++i) {
|
||||
buff.put(NewCurveStyleState.unitCone[i * 6 + 0]);
|
||||
buff.put(NewCurveStyleState.unitCone[i * 6 + 1]);
|
||||
buff.put(offx + (x1 + radius * NewCurveStyleState.unitCone[i * 6 + 2]) / divx);
|
||||
buff.put(offy - (y1 + radius * NewCurveStyleState.unitCone[i * 6 + 3]) / divy);
|
||||
buff.put(offx + (x1 + radius * NewCurveStyleState.unitCone[i * 6 + 2]) / width2);
|
||||
buff.put(offy - (y1 + radius * NewCurveStyleState.unitCone[i * 6 + 3]) / height2);
|
||||
buff.put(NewCurveStyleState.unitCone[i * 6 + 4]);
|
||||
buff.put(NewCurveStyleState.unitCone[i * 6 + 5]);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
|
||||
@Override
|
||||
protected float getBaseY() {
|
||||
return displayContainer.height * 2f / 3;
|
||||
return height * 2f / 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,10 +203,9 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
float mult = GameMod.getScoreMultiplier();
|
||||
String multString = String.format("Score Multiplier: %.2fx", mult);
|
||||
Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red;
|
||||
float multY = Fonts.LARGE.getLineHeight() * 2 + displayContainer.height * 0.06f;
|
||||
Fonts.LARGE.drawString(
|
||||
(displayContainer.width - Fonts.LARGE.getWidth(multString)) / 2f,
|
||||
multY, multString, multColor);
|
||||
float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f;
|
||||
final float multX = width2 - Fonts.LARGE.getWidth(multString) / 2f;
|
||||
Fonts.LARGE.drawString(multX, multY, multString, multColor);
|
||||
|
||||
// category text
|
||||
for (GameMod.Category category : GameMod.Category.values()) {
|
||||
@@ -296,13 +295,12 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
* Initializes the menu state.
|
||||
*/
|
||||
public void revalidate(Image button, Image buttonL, Image buttonR) {
|
||||
float center = displayContainer.width / 2;
|
||||
float baseY = getBaseY();
|
||||
float offsetY = button.getHeight() * 1.25f;
|
||||
|
||||
menuButtons = new MenuButton[buttons.length];
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
MenuButton b = new MenuButton(button, buttonL, buttonR, center, baseY + (i * offsetY));
|
||||
MenuButton b = new MenuButton(button, buttonL, buttonR, width2, baseY + (i * offsetY));
|
||||
b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Fonts.XLARGE, Color.white);
|
||||
b.setHoverFade();
|
||||
menuButtons[i] = b;
|
||||
@@ -313,7 +311,7 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
* Returns the base Y coordinate for the buttons.
|
||||
*/
|
||||
protected float getBaseY() {
|
||||
float baseY = displayContainer.height * 0.2f;
|
||||
float baseY = height * 0.2f;
|
||||
baseY += ((getTitle().length - 1) * Fonts.LARGE.getLineHeight());
|
||||
return baseY;
|
||||
}
|
||||
@@ -325,7 +323,7 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
public void render(Graphics g) {
|
||||
// draw title
|
||||
if (actualTitle != null) {
|
||||
float marginX = displayContainer.width * 0.015f, marginY = displayContainer.height * 0.01f;
|
||||
float marginX = width * 0.015f, marginY = height * 0.01f;
|
||||
int lineHeight = Fonts.LARGE.getLineHeight();
|
||||
for (int i = 0, size = actualTitle.size(); i < size; i++)
|
||||
Fonts.LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
|
||||
@@ -342,15 +340,16 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
* Updates the menu state.
|
||||
*/
|
||||
public void preRenderUpdate() {
|
||||
float center = displayContainer.width / 2f;
|
||||
boolean centerOffsetUpdated = centerOffset.update(displayContainer.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);
|
||||
|
||||
// move button to center
|
||||
if (centerOffsetUpdated)
|
||||
menuButtons[i].setX((i % 2 == 0) ? center + centerOffsetX : center - centerOffsetX);
|
||||
if (centerOffsetUpdated) {
|
||||
menuButtons[i].setX(width2 + offsets[i & 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,18 +393,17 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
* Processes a state enter request.
|
||||
*/
|
||||
public void enter() {
|
||||
float center = displayContainer.width / 2f;
|
||||
float centerOffsetX = displayContainer.width * OFFSET_WIDTH_RATIO;
|
||||
float centerOffsetX = width * OFFSET_WIDTH_RATIO;
|
||||
centerOffset = new AnimatedValue(700, centerOffsetX, 0, AnimationEquation.OUT_BOUNCE);
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
menuButtons[i].setX(center + ((i % 2 == 0) ? centerOffsetX : centerOffsetX * -1));
|
||||
menuButtons[i].setX(width2 + ((i % 2 == 0) ? centerOffsetX : centerOffsetX * -1));
|
||||
menuButtons[i].resetHover();
|
||||
}
|
||||
|
||||
// create title string list
|
||||
actualTitle = new ArrayList<>();
|
||||
String[] title = getTitle();
|
||||
int maxLineWidth = (int) (displayContainer.width * 0.96f);
|
||||
int maxLineWidth = (int) (width * 0.96f);
|
||||
for (String aTitle : title) {
|
||||
// wrap text if too long
|
||||
if (Fonts.LARGE.getWidth(aTitle) > maxLineWidth) {
|
||||
@@ -601,7 +599,7 @@ public class ButtonMenu extends BaseOpsuState {
|
||||
|
||||
// initialize buttons
|
||||
Image button = GameImage.MENU_BUTTON_MID.getImage();
|
||||
button = button.getScaledCopy(displayContainer.width / 2, button.getHeight());
|
||||
button = button.getScaledCopy(width2, button.getHeight());
|
||||
Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage();
|
||||
Image buttonR = GameImage.MENU_BUTTON_RIGHT.getImage();
|
||||
for (MenuState ms : MenuState.values()) {
|
||||
|
||||
@@ -293,8 +293,6 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
|
||||
components.clear();
|
||||
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
int baseX = (int) (width * 0.024f);
|
||||
int searchY = (int) (height * 0.04f + Fonts.LARGE.getLineHeight());
|
||||
int searchWidth = (int) (width * 0.3f);
|
||||
@@ -409,7 +407,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
GameImage.SEARCH_BG.getImage().draw();
|
||||
|
||||
// title
|
||||
Fonts.LARGE.drawString(displayContainer.width * 0.024f, displayContainer.height * 0.03f, "Download Beatmaps!", Color.white);
|
||||
Fonts.LARGE.drawString(width * 0.024f, height * 0.03f, "Download Beatmaps!", Color.white);
|
||||
|
||||
// search
|
||||
g.setColor(Color.white);
|
||||
@@ -446,9 +444,9 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
|
||||
// pages
|
||||
if (nodes.length > 0) {
|
||||
float baseX = displayContainer.width * 0.024f;
|
||||
float buttonY = displayContainer.height * 0.2f;
|
||||
float buttonWidth = displayContainer.width * 0.7f;
|
||||
float baseX = width * 0.024f;
|
||||
float buttonY = height * 0.2f;
|
||||
float buttonWidth = width * 0.7f;
|
||||
Fonts.BOLD.drawString(
|
||||
baseX + (buttonWidth - Fonts.BOLD.getWidth("Page 1")) / 2f,
|
||||
buttonY - Fonts.BOLD.getLineHeight() * 1.3f,
|
||||
@@ -462,11 +460,10 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
}
|
||||
|
||||
// downloads
|
||||
float downloadsX = displayContainer.width * 0.75f, downloadsY = search.y;
|
||||
float downloadsX = width * 0.75f, downloadsY = search.y;
|
||||
g.setColor(Colors.BLACK_BG_NORMAL);
|
||||
g.fillRect(downloadsX, downloadsY,
|
||||
displayContainer.width * 0.25f, displayContainer.height - downloadsY * 2f);
|
||||
Fonts.LARGE.drawString(downloadsX + displayContainer.width * 0.015f, downloadsY + displayContainer.height * 0.015f, "Downloads", Color.white);
|
||||
g.fillRect(downloadsX, downloadsY, width * 0.25f, height - downloadsY * 2f);
|
||||
Fonts.LARGE.drawString(downloadsX + width * 0.015f, downloadsY + height * 0.015f, "Downloads", Color.white);
|
||||
int downloadsSize = DownloadList.get().size();
|
||||
if (downloadsSize > 0) {
|
||||
int maxDownloadsShown = DownloadNode.maxDownloadsShown();
|
||||
@@ -505,15 +502,13 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
if (importThread != null) {
|
||||
// darken the screen
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, 0, displayContainer.width, displayContainer.height);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
UI.drawLoadingProgress(g);
|
||||
} else {
|
||||
backButton.draw(g);
|
||||
}
|
||||
|
||||
// back button
|
||||
else
|
||||
UI.getBackButton().draw(g);
|
||||
|
||||
UI.draw(g);
|
||||
}
|
||||
|
||||
@@ -544,7 +539,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
}
|
||||
int mouseX = displayContainer.mouseX;
|
||||
int mouseY = displayContainer.mouseY;
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
backButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
prevPage.hoverUpdate(delta, mouseX, mouseY);
|
||||
nextPage.hoverUpdate(delta, mouseX, mouseY);
|
||||
clearButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
@@ -614,7 +609,7 @@ public class DownloadsMenu extends ComplexOpsuState {
|
||||
}
|
||||
|
||||
// back
|
||||
if (UI.getBackButton().contains(x, y)) {
|
||||
if (backButton.contains(x, y)) {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
displayContainer.switchState(mainmenuState);
|
||||
return true;
|
||||
|
||||
@@ -24,6 +24,7 @@ import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
import itdelatrisu.opsu.beatmap.HitObject;
|
||||
import itdelatrisu.opsu.beatmap.TimingPoint;
|
||||
import itdelatrisu.opsu.db.BeatmapDB;
|
||||
@@ -317,7 +318,7 @@ public class Game extends ComplexOpsuState {
|
||||
mirrorCursor = new Cursor(true);
|
||||
this.moveStoryboardOverlay = new MoveStoryboard(displayContainer);
|
||||
this.optionsOverlay = new OptionsOverlay(displayContainer, OptionGroups.storyboardOptions);
|
||||
this.storyboardOverlay = new StoryboardOverlay(displayContainer, moveStoryboardOverlay, optionsOverlay, this);
|
||||
this.storyboardOverlay = new StoryboardOverlay(moveStoryboardOverlay, optionsOverlay, this);
|
||||
storyboardOverlay.show();
|
||||
moveStoryboardOverlay.show();
|
||||
optionsOverlay.setListener(storyboardOverlay);
|
||||
@@ -329,7 +330,7 @@ public class Game extends ComplexOpsuState {
|
||||
|
||||
// create offscreen graphics
|
||||
try {
|
||||
offscreen = new Image(displayContainer.width, displayContainer.height);
|
||||
offscreen = new Image(width, height);
|
||||
gOffscreen = offscreen.getGraphics();
|
||||
gOffscreen.setBackground(Color.black);
|
||||
} catch (SlickException e) {
|
||||
@@ -341,14 +342,14 @@ public class Game extends ComplexOpsuState {
|
||||
}
|
||||
|
||||
// initialize music position bar location
|
||||
musicBarX = displayContainer.width * 0.01f;
|
||||
musicBarY = displayContainer.height * 0.05f;
|
||||
musicBarWidth = Math.max(displayContainer.width * 0.005f, 7);
|
||||
musicBarHeight = displayContainer.height * 0.9f;
|
||||
musicBarX = width * 0.01f;
|
||||
musicBarY = height * 0.05f;
|
||||
musicBarWidth = Math.max(width * 0.005f, 7);
|
||||
musicBarHeight = height * 0.9f;
|
||||
|
||||
// initialize scoreboard star stream
|
||||
scoreboardStarStream = new StarStream(0, displayContainer.height * 2f / 3f, displayContainer.width / 4, 0, 0);
|
||||
scoreboardStarStream.setPositionSpread(displayContainer.height / 20f);
|
||||
scoreboardStarStream = new StarStream(0, height * 2f / 3f, width / 4, 0, 0);
|
||||
scoreboardStarStream.setPositionSpread(height / 20f);
|
||||
scoreboardStarStream.setDirectionSpread(10f);
|
||||
scoreboardStarStream.setDurationSpread(700, 100);
|
||||
|
||||
@@ -382,9 +383,6 @@ public class Game extends ComplexOpsuState {
|
||||
|
||||
@Override
|
||||
public void render(Graphics g) {
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
|
||||
int trackPosition = MusicController.getPosition();
|
||||
if (isLeadIn()) {
|
||||
trackPosition -= leadInTime - currentMapMusicOffset - OPTION_MUSIC_OFFSET.val;
|
||||
@@ -637,7 +635,7 @@ public class Game extends ComplexOpsuState {
|
||||
float animation = AnimationEquation.IN_OUT_QUAD.calc(
|
||||
Utils.clamp((trackPosition - lastRankUpdateTime) / SCOREBOARD_ANIMATION_TIME, 0f, 1f)
|
||||
);
|
||||
int scoreboardPosition = 2 * displayContainer.height / 3;
|
||||
int scoreboardPosition = 2 * height / 3;
|
||||
|
||||
// draw star stream behind the scores
|
||||
scoreboardStarStream.draw();
|
||||
@@ -907,11 +905,11 @@ public class Game extends ComplexOpsuState {
|
||||
} else if (GameMod.AUTO.isActive()) {
|
||||
displayContainer.cursor.setCursorPosition(displayContainer.delta, (int) autoMousePosition.x, (int) autoMousePosition.y);
|
||||
if (OPTION_DANCE_MIRROR.state && GameMod.AUTO.isActive()) {
|
||||
double dx = autoMousePosition.x - displayContainer.width / 2d;
|
||||
double dy = autoMousePosition.y - displayContainer.height / 2d;
|
||||
double dx = autoMousePosition.x - width2;
|
||||
double dy = autoMousePosition.y - height2;
|
||||
double d = Math.sqrt(dx * dx + dy * dy);
|
||||
double a = Math.atan2(dy, dx) + Math.PI;
|
||||
mirrorCursor.setCursorPosition(displayContainer.delta, (int) (Math.cos(a) * d + displayContainer.width / 2), (int) (Math.sin(a) * d + displayContainer.height / 2));
|
||||
mirrorCursor.setCursorPosition(displayContainer.delta, (int) (Math.cos(a) * d + width2), (int) (Math.sin(a) * d + height2));
|
||||
}
|
||||
} else if (GameMod.AUTOPILOT.isActive()) {
|
||||
displayContainer.cursor.setCursorPosition(displayContainer.delta, (int) autoMousePosition.x, (int) autoMousePosition.y);
|
||||
@@ -1477,10 +1475,9 @@ public class Game extends ComplexOpsuState {
|
||||
epiImgTime = OPTION_EPILEPSY_WARNING.val * 100;
|
||||
if (epiImgTime > 0) {
|
||||
epiImg = GameImage.EPILEPSY_WARNING.getImage();
|
||||
float desWidth = displayContainer.width / 2;
|
||||
epiImg = epiImg.getScaledCopy(desWidth / epiImg.getWidth());
|
||||
epiImgX = (displayContainer.width - epiImg.getWidth()) / 2;
|
||||
epiImgY = (displayContainer.height - epiImg.getHeight()) / 2;
|
||||
epiImg = epiImg.getScaledCopy(width2 / epiImg.getWidth());
|
||||
epiImgX = width2 - epiImg.getWidth() / 2;
|
||||
epiImgY = height2 - epiImg.getHeight() / 2;
|
||||
}
|
||||
|
||||
// load mods
|
||||
@@ -1582,8 +1579,8 @@ public class Game extends ComplexOpsuState {
|
||||
// load replay frames
|
||||
if (isReplay) {
|
||||
// load initial data
|
||||
replayX = displayContainer.width / 2;
|
||||
replayY = displayContainer.height / 2;
|
||||
replayX = width2;
|
||||
replayY = height2;
|
||||
replayKeyPressed = false;
|
||||
replaySkipTime = -1;
|
||||
for (replayIndex = 0; replayIndex < replay.frames.length; replayIndex++) {
|
||||
@@ -1775,7 +1772,7 @@ public class Game extends ComplexOpsuState {
|
||||
}
|
||||
if (lastObjectIndex != -1 && !beatmap.objects[index].isNewCombo()) {
|
||||
// calculate points
|
||||
final int followPointInterval = displayContainer.height / 14;
|
||||
final int followPointInterval = height / 14;
|
||||
int lastObjectEndTime = gameObjects[lastObjectIndex].getEndTime() + 1;
|
||||
int objectStartTime = beatmap.objects[index].getTime();
|
||||
Vec2f startPoint = gameObjects[lastObjectIndex].getPointAt(lastObjectEndTime);
|
||||
@@ -1836,7 +1833,7 @@ public class Game extends ComplexOpsuState {
|
||||
gameObj.draw(g, trackPosition, false);
|
||||
if (OPTION_DANCE_MIRROR.state && GameMod.AUTO.isActive() && idx < mirrorTo && idx >= mirrorFrom) {
|
||||
g.pushTransform();
|
||||
g.rotate(displayContainer.width / 2f, displayContainer.height / 2f, 180f);
|
||||
g.rotate(width2, height2, 180f);
|
||||
gameObj.draw(g, trackPosition, true);
|
||||
g.popTransform();
|
||||
}
|
||||
@@ -1864,7 +1861,7 @@ public class Game extends ComplexOpsuState {
|
||||
g.pushTransform();
|
||||
|
||||
// translate and rotate the object
|
||||
g.translate(0, dt * dt * displayContainer.height);
|
||||
g.translate(0, dt * dt * height);
|
||||
Vec2f rotationCenter = gameObj.getPointAt((beatmap.objects[idx].getTime() + beatmap.objects[idx].getEndTime()) / 2);
|
||||
g.rotate(rotationCenter.x, rotationCenter.y, rotSpeed * dt);
|
||||
gameObj.draw(g, trackPosition, false);
|
||||
@@ -1887,7 +1884,7 @@ public class Game extends ComplexOpsuState {
|
||||
if (beatmap.breaks == null) {
|
||||
BeatmapDB.load(beatmap, BeatmapDB.LOAD_ARRAY);
|
||||
}
|
||||
beatmapParser.parseHitObjects(beatmap);
|
||||
BeatmapParser.parseHitObjects(beatmap);
|
||||
HitSound.setDefaultSampleSet(beatmap.sampleSet);
|
||||
}
|
||||
|
||||
@@ -1918,7 +1915,7 @@ public class Game extends ComplexOpsuState {
|
||||
lastReplayTime = 0;
|
||||
autoMousePosition = new Vec2f();
|
||||
autoMousePressed = false;
|
||||
flashlightRadius = displayContainer.height * 2 / 3;
|
||||
flashlightRadius = height * 2 / 3;
|
||||
if (scoreboardStarStream != null) {
|
||||
scoreboardStarStream.clear();
|
||||
}
|
||||
@@ -1970,10 +1967,10 @@ public class Game extends ComplexOpsuState {
|
||||
// skip button
|
||||
if (GameImage.SKIP.getImages() != null) {
|
||||
Animation skip = GameImage.SKIP.getAnimation(120);
|
||||
skipButton = new MenuButton(skip, displayContainer.width - skip.getWidth() / 2f, displayContainer.height - (skip.getHeight() / 2f));
|
||||
skipButton = new MenuButton(skip, width - skip.getWidth() / 2f, height - (skip.getHeight() / 2f));
|
||||
} else {
|
||||
Image skip = GameImage.SKIP.getImage();
|
||||
skipButton = new MenuButton(skip, displayContainer.width - skip.getWidth() / 2f, displayContainer.height - (skip.getHeight() / 2f));
|
||||
skipButton = new MenuButton(skip, width - skip.getWidth() / 2f, height - (skip.getHeight() / 2f));
|
||||
}
|
||||
skipButton.setHoverAnimationDuration(350);
|
||||
skipButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
@@ -2018,12 +2015,12 @@ public class Game extends ComplexOpsuState {
|
||||
// initialize objects
|
||||
gameObjectRenderer.initForGame(data, diameter);
|
||||
Slider.init(gameObjectRenderer.circleDiameter, beatmap);
|
||||
Spinner.init(displayContainer, overallDifficulty);
|
||||
Spinner.init(overallDifficulty);
|
||||
Color sliderBorderColor = SkinService.skin.getSliderBorderColor();
|
||||
if (!OPTION_IGNORE_BEATMAP_SKINS.state && beatmap.getSliderBorderColor() != null) {
|
||||
sliderBorderColor = beatmap.getSliderBorderColor();
|
||||
}
|
||||
Curve.init(displayContainer.width, displayContainer.height, diameter, sliderBorderColor);
|
||||
Curve.init(diameter, sliderBorderColor);
|
||||
|
||||
// approachRate (hit object approach time)
|
||||
if (approachRate < 5)
|
||||
@@ -2242,25 +2239,25 @@ public class Game extends ComplexOpsuState {
|
||||
if (isLeadIn()) {
|
||||
// lead-in: expand area
|
||||
float progress = Math.max((float) (leadInTime - beatmap.audioLeadIn) / approachTime, 0f);
|
||||
flashlightRadius = displayContainer.width - (int) ((displayContainer.width - (displayContainer.height * 2 / 3)) * progress);
|
||||
flashlightRadius = width - (int) ((width - (height * 2 / 3)) * progress);
|
||||
} else if (firstObject) {
|
||||
// before first object: shrink area
|
||||
int timeDiff = beatmap.objects[0].getTime() - trackPosition;
|
||||
flashlightRadius = displayContainer.width;
|
||||
flashlightRadius = width;
|
||||
if (timeDiff < approachTime) {
|
||||
float progress = (float) timeDiff / approachTime;
|
||||
flashlightRadius -= (displayContainer.width - (displayContainer.height * 2 / 3)) * (1 - progress);
|
||||
flashlightRadius -= (width - (height * 2 / 3)) * (1 - progress);
|
||||
}
|
||||
} else {
|
||||
// gameplay: size based on combo
|
||||
int targetRadius;
|
||||
int combo = data.getComboStreak();
|
||||
if (combo < 100)
|
||||
targetRadius = displayContainer.height * 2 / 3;
|
||||
targetRadius = height * 2 / 3;
|
||||
else if (combo < 200)
|
||||
targetRadius = displayContainer.height / 2;
|
||||
targetRadius = height2;
|
||||
else
|
||||
targetRadius = displayContainer.height / 3;
|
||||
targetRadius = height / 3;
|
||||
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size() && breakTime > 0) {
|
||||
// breaks: expand at beginning, shrink at end
|
||||
flashlightRadius = targetRadius;
|
||||
@@ -2272,11 +2269,11 @@ public class Game extends ComplexOpsuState {
|
||||
progress = (float) (trackPosition - breakTime) / approachTime;
|
||||
else if (endTime - trackPosition < approachTime)
|
||||
progress = (float) (endTime - trackPosition) / approachTime;
|
||||
flashlightRadius += (displayContainer.width - flashlightRadius) * progress;
|
||||
flashlightRadius += (width - flashlightRadius) * progress;
|
||||
}
|
||||
} else if (flashlightRadius != targetRadius) {
|
||||
// radius size change
|
||||
float radiusDiff = displayContainer.height * delta / 2000f;
|
||||
float radiusDiff = height * delta / 2000f;
|
||||
if (flashlightRadius > targetRadius) {
|
||||
flashlightRadius -= radiusDiff;
|
||||
if (flashlightRadius < targetRadius)
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||
|
||||
import static itdelatrisu.opsu.GameImage.*;
|
||||
import static org.lwjgl.input.Keyboard.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
@@ -193,9 +194,9 @@ public class GamePauseMenu extends BaseOpsuState {
|
||||
*/
|
||||
public void loadImages() {
|
||||
// initialize buttons
|
||||
continueButton = new MenuButton(GameImage.PAUSE_CONTINUE.getImage(), displayContainer.width / 2f, displayContainer.height * 0.25f);
|
||||
retryButton = new MenuButton(GameImage.PAUSE_RETRY.getImage(), displayContainer.width / 2f, displayContainer.height * 0.5f);
|
||||
backButton = new MenuButton(GameImage.PAUSE_BACK.getImage(), displayContainer.width / 2f, displayContainer.height * 0.75f);
|
||||
continueButton = new MenuButton(PAUSE_CONTINUE.getImage(), width2, height * 0.25f);
|
||||
retryButton = new MenuButton(PAUSE_RETRY.getImage(), width2, height2);
|
||||
backButton = new MenuButton(PAUSE_BACK.getImage(), width2, height * 0.75f);
|
||||
final int buttonAnimationDuration = 300;
|
||||
continueButton.setHoverAnimationDuration(buttonAnimationDuration);
|
||||
retryButton.setHoverAnimationDuration(buttonAnimationDuration);
|
||||
|
||||
@@ -66,10 +66,10 @@ public class GameRanking extends BaseOpsuState {
|
||||
// buttons
|
||||
Image retry = GameImage.PAUSE_RETRY.getImage();
|
||||
Image replay = GameImage.PAUSE_REPLAY.getImage();
|
||||
replayY = (displayContainer.height * 0.985f) - replay.getHeight() / 2f;
|
||||
replayY = height * 0.985f - replay.getHeight() / 2f;
|
||||
retryY = replayY - (replay.getHeight() / 2f) - (retry.getHeight() / 1.975f);
|
||||
retryButton = new MenuButton(retry, displayContainer.width - (retry.getWidth() / 2f), retryY);
|
||||
replayButton = new MenuButton(replay, displayContainer.width - (replay.getWidth() / 2f), replayY);
|
||||
retryButton = new MenuButton(retry, width - (retry.getWidth() / 2f), retryY);
|
||||
replayButton = new MenuButton(replay, width - (replay.getWidth() / 2f), replayY);
|
||||
retryButton.setHoverFade();
|
||||
replayButton.setHoverFade();
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class GameRanking extends BaseOpsuState {
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
|
||||
// background
|
||||
if (!beatmap.drawBackground(displayContainer.width, displayContainer.height, 0.7f, true)) {
|
||||
if (!beatmap.drawBackground(width, height, 0.7f, true)) {
|
||||
GameImage.PLAYFIELD.getImage().draw(0, 0);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class GameRanking extends BaseOpsuState {
|
||||
replayButton.draw();
|
||||
if (data.isGameplay() && !GameMod.AUTO.isActive())
|
||||
retryButton.draw();
|
||||
UI.getBackButton().draw(g);
|
||||
backButton.draw(g);
|
||||
|
||||
UI.draw(g);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class GameRanking extends BaseOpsuState {
|
||||
} else {
|
||||
MusicController.loopTrackIfEnded(true);
|
||||
}
|
||||
UI.getBackButton().hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
|
||||
backButton.hoverUpdate(delta, displayContainer.mouseX, displayContainer.mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +139,7 @@ public class GameRanking extends BaseOpsuState {
|
||||
}
|
||||
|
||||
// back to menu
|
||||
if (UI.getBackButton().contains(x, y)) {
|
||||
if (backButton.contains(x, y)) {
|
||||
returnToSongMenu();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,9 +172,6 @@ public class MainMenu extends BaseOpsuState {
|
||||
protected void revalidate() {
|
||||
previous = new Stack<>();
|
||||
|
||||
final int width = displayContainer.width;
|
||||
final int height = displayContainer.height;
|
||||
|
||||
this.barHeight = height * 0.1125f;
|
||||
|
||||
this.textMarginX = (int) (width * 0.015f);
|
||||
@@ -213,7 +210,7 @@ public class MainMenu extends BaseOpsuState {
|
||||
|
||||
// initialize downloads button
|
||||
Image dlImg = GameImage.DOWNLOADS.getImage();
|
||||
downloadsButton = new MenuButton(dlImg, displayContainer.width - dlImg.getWidth() / 2f, displayContainer.height / 2f);
|
||||
downloadsButton = new MenuButton(dlImg, width - dlImg.getWidth() / 2f, height2);
|
||||
downloadsButton.setHoverAnimationDuration(350);
|
||||
downloadsButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
downloadsButton.setHoverExpand(1.03f, Expand.LEFT);
|
||||
@@ -233,31 +230,31 @@ public class MainMenu extends BaseOpsuState {
|
||||
}
|
||||
|
||||
// initialize update buttons
|
||||
float updateX = displayContainer.width / 2f, updateY = displayContainer.height * 17 / 18f;
|
||||
Image downloadImg = GameImage.DOWNLOAD.getImage();
|
||||
updateButton = new MenuButton(downloadImg, updateX, updateY);
|
||||
final float updateY = height * 17 / 18f;
|
||||
final Image downloadImg = GameImage.DOWNLOAD.getImage();
|
||||
updateButton = new MenuButton(downloadImg, width2, updateY);
|
||||
updateButton.setHoverAnimationDuration(400);
|
||||
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
|
||||
updateButton.setHoverExpand(1.1f);
|
||||
Image updateImg = GameImage.UPDATE.getImage();
|
||||
restartButton = new MenuButton(updateImg, updateX, updateY);
|
||||
final Image updateImg = GameImage.UPDATE.getImage();
|
||||
restartButton = new MenuButton(updateImg, width2, updateY);
|
||||
restartButton.setHoverAnimationDuration(2000);
|
||||
restartButton.setHoverAnimationEquation(AnimationEquation.LINEAR);
|
||||
restartButton.setHoverRotate(360);
|
||||
|
||||
// initialize star fountain
|
||||
starFountain = new StarFountain(displayContainer.width, displayContainer.height);
|
||||
starFountain = new StarFountain(width, height);
|
||||
|
||||
// logo & buttons
|
||||
this.logo = new ImagePosition(MENU_LOGO.getImage());
|
||||
logoPositionOffsetX = 0.35f * MENU_LOGO.getImage().getHeight();
|
||||
logoPosition = new AnimatedValue(1, 0, 1, AnimationEquation.OUT_QUAD);
|
||||
logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||
this.buttonsX = (displayContainer.width - MENU_OPTIONS.getImage().getWidth()) / 2;
|
||||
this.buttonsX = width2 - MENU_OPTIONS.getImage().getWidth() / 2;
|
||||
this.buttonPositions[0] = new ImagePosition(MENU_PLAY.getImage());
|
||||
this.buttonPositions[1] = new ImagePosition(MENU_OPTIONS.getImage());
|
||||
this.buttonPositions[2] = new ImagePosition(MENU_EXIT.getImage());
|
||||
final int basey = displayContainer.height / 2 - MENU_OPTIONS.getImage().getHeight() / 2;
|
||||
final int basey = height2 - MENU_OPTIONS.getImage().getHeight() / 2;
|
||||
final float yoffset = MENU_LOGO.getImage().getHeight() * 0.196378f;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
this.buttonPositions[i].width = MENU_OPTIONS.getImage().getWidth();
|
||||
@@ -268,9 +265,6 @@ public class MainMenu extends BaseOpsuState {
|
||||
|
||||
@Override
|
||||
public void render(Graphics g) {
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
|
||||
// draw background
|
||||
Beatmap beatmap = MusicController.getBeatmap();
|
||||
if (OPTION_DYNAMIC_BACKGROUND.state &&
|
||||
@@ -339,7 +333,7 @@ public class MainMenu extends BaseOpsuState {
|
||||
if (this.logoState != LogoState.DEFAULT && buttonProgress > 0f) {
|
||||
final int btnwidth = MENU_OPTIONS.getImage().getWidth();
|
||||
final float btnhalfheight = MENU_OPTIONS.getImage().getHeight() / 2f;
|
||||
final int basey = displayContainer.height / 2;
|
||||
final int basey = height2;
|
||||
final int x = (int) (this.buttonsX + btnwidth * 0.375f * buttonProgress);
|
||||
final Color col = new Color(logoColor);
|
||||
final Image[] imgs = {
|
||||
@@ -528,8 +522,8 @@ public class MainMenu extends BaseOpsuState {
|
||||
// buttons
|
||||
this.logo.width = MENU_LOGO.getImage().getWidth();
|
||||
this.logo.height = MENU_LOGO.getImage().getHeight();
|
||||
this.logo.x = (displayContainer.width - this.logo.width) / 2;
|
||||
this.logo.y = (displayContainer.height - this.logo.height) / 2;
|
||||
this.logo.x = width2 - this.logo.width / 2;
|
||||
this.logo.y = height2 - this.logo.height / 2;
|
||||
if (this.logoState != LogoState.DEFAULT) {
|
||||
this.logo.x -= (int) this.logoPosition.getValue();
|
||||
}
|
||||
|
||||
@@ -325,23 +325,23 @@ public class SongMenu extends ComplexOpsuState {
|
||||
components.clear();
|
||||
|
||||
// header/footer coordinates
|
||||
headerY = displayContainer.height * 0.0075f + GameImage.MENU_MUSICNOTE.getImage().getHeight() +
|
||||
headerY = height * 0.0075f + GameImage.MENU_MUSICNOTE.getImage().getHeight() +
|
||||
Fonts.BOLD.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
||||
Fonts.SMALL.getLineHeight();
|
||||
footerY = displayContainer.height - GameImage.SELECTION_MODS.getImage().getHeight();
|
||||
footerY = height - GameImage.SELECTION_MODS.getImage().getHeight();
|
||||
|
||||
// footer logo coordinates
|
||||
float footerHeight = displayContainer.height - footerY;
|
||||
float footerHeight = height - footerY;
|
||||
footerLogoSize = footerHeight * 3.25f;
|
||||
Image logo = GameImage.MENU_LOGO.getImage();
|
||||
logo = logo.getScaledCopy(footerLogoSize / logo.getWidth());
|
||||
footerLogoButton = new MenuButton(logo, displayContainer.width - footerHeight * 0.8f, displayContainer.height - footerHeight * 0.65f);
|
||||
footerLogoButton = new MenuButton(logo, width - footerHeight * 0.8f, height - footerHeight * 0.65f);
|
||||
footerLogoButton.setHoverAnimationDuration(1);
|
||||
footerLogoButton.setHoverExpand(1.2f);
|
||||
|
||||
// initialize sorts
|
||||
int sortWidth = (int) (displayContainer.width * 0.12f);
|
||||
int posX = (int) (displayContainer.width * 0.87f);
|
||||
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) {
|
||||
@Override
|
||||
@@ -372,25 +372,25 @@ public class SongMenu extends ComplexOpsuState {
|
||||
|
||||
// initialize group tabs
|
||||
for (BeatmapGroup group : BeatmapGroup.values())
|
||||
group.init(displayContainer.width, headerY - DIVIDER_LINE_WIDTH / 2);
|
||||
group.init(width, headerY - DIVIDER_LINE_WIDTH / 2);
|
||||
|
||||
// initialize score data buttons
|
||||
ScoreData.init(displayContainer.width, headerY + displayContainer.height * 0.01f);
|
||||
ScoreData.init(width, headerY + height * 0.01f);
|
||||
|
||||
// song button background & graphics context
|
||||
Image menuBackground = GameImage.MENU_BUTTON_BG.getImage();
|
||||
|
||||
// song button coordinates
|
||||
buttonX = displayContainer.width * 0.6f;
|
||||
buttonX = width * 0.6f;
|
||||
//buttonY = headerY;
|
||||
buttonWidth = menuBackground.getWidth();
|
||||
buttonHeight = menuBackground.getHeight();
|
||||
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
||||
|
||||
// search
|
||||
int textFieldX = (int) (displayContainer.width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
||||
int textFieldX = (int) (width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
||||
int textFieldY = (int) (headerY + Fonts.BOLD.getLineHeight() / 2);
|
||||
searchTextField = new TextField(Fonts.BOLD, textFieldX, textFieldY, (int) (displayContainer.width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()) {
|
||||
searchTextField = new TextField(Fonts.BOLD, textFieldX, textFieldY, (int) (width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()) {
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return false;
|
||||
@@ -413,8 +413,8 @@ public class SongMenu extends ComplexOpsuState {
|
||||
if (selectButtonsWidth < 20) {
|
||||
selectButtonsWidth = 100;
|
||||
}
|
||||
float selectX = displayContainer.width * 0.183f + selectButtonsWidth / 2f;
|
||||
float selectY = displayContainer.height - selectButtonsHeight / 2f;
|
||||
float selectX = width * 0.183f + selectButtonsWidth / 2f;
|
||||
float selectY = height - selectButtonsHeight / 2f;
|
||||
float selectOffset = selectButtonsWidth * 1.05f;
|
||||
selectModsButton = new MenuButton(GameImage.SELECTION_MODS_OVERLAY.getImage(),
|
||||
selectX, selectY);
|
||||
@@ -450,8 +450,8 @@ public class SongMenu extends ComplexOpsuState {
|
||||
});
|
||||
|
||||
// star stream
|
||||
starStream = new StarStream(displayContainer.width, (displayContainer.height - GameImage.STAR.getImage().getHeight()) / 2, -displayContainer.width, 0, MAX_STREAM_STARS);
|
||||
starStream.setPositionSpread(displayContainer.height / 20f);
|
||||
starStream = new StarStream(width, height2 - GameImage.STAR.getImage().getHeight() / 2, -width, 0, MAX_STREAM_STARS);
|
||||
starStream.setPositionSpread(height / 20f);
|
||||
starStream.setDirectionSpread(10f);
|
||||
}
|
||||
|
||||
@@ -459,8 +459,6 @@ public class SongMenu extends ComplexOpsuState {
|
||||
public void render(Graphics g) {
|
||||
g.setBackground(Color.black);
|
||||
|
||||
int width = displayContainer.width;
|
||||
int height = displayContainer.height;
|
||||
int mouseX = displayContainer.mouseX;
|
||||
int mouseY = displayContainer.mouseY;
|
||||
|
||||
@@ -697,12 +695,10 @@ public class SongMenu extends ComplexOpsuState {
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
UI.drawLoadingProgress(g);
|
||||
} else {
|
||||
backButton.draw(g);
|
||||
}
|
||||
|
||||
// back button
|
||||
else
|
||||
UI.getBackButton().draw(g);
|
||||
|
||||
UI.draw(g);
|
||||
|
||||
super.render(g);
|
||||
@@ -730,7 +726,7 @@ public class SongMenu extends ComplexOpsuState {
|
||||
}
|
||||
int mouseX = displayContainer.mouseX;
|
||||
int mouseY = displayContainer.mouseY;
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
backButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
selectModsButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
selectRandomButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
selectMapOptionsButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
@@ -904,7 +900,7 @@ public class SongMenu extends ComplexOpsuState {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (UI.getBackButton().contains(x, y)) {
|
||||
if (backButton.contains(x, y)) {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
displayContainer.switchState(mainmenuState);
|
||||
return true;
|
||||
|
||||
@@ -107,11 +107,13 @@ public class Splash extends BaseOpsuState {
|
||||
@Override
|
||||
public void render(Graphics g) {
|
||||
g.setBackground(Color.black);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(
|
||||
displayContainer.width / 2,
|
||||
displayContainer.height / 2,
|
||||
OPTION_COLOR_MAIN_MENU_LOGO.state ? Cursor.lastCursorColor : Color.white
|
||||
);
|
||||
final Color col;
|
||||
if (OPTION_COLOR_MAIN_MENU_LOGO.state) {
|
||||
col = Cursor.lastCursorColor;
|
||||
} else {
|
||||
col = Color.white;
|
||||
}
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(width2, height2, col);
|
||||
UI.drawLoadingProgress(g);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.ui.BackButton;
|
||||
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
@@ -39,9 +37,6 @@ import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
*/
|
||||
public class UI {
|
||||
|
||||
/** Back button. */
|
||||
private static BackButton backButton;
|
||||
|
||||
/** Time to show volume image, in milliseconds. */
|
||||
private static final int VOLUME_DISPLAY_TIME = 1500;
|
||||
|
||||
@@ -57,20 +52,9 @@ public class UI {
|
||||
/** The alpha level of the current tooltip (if any). */
|
||||
private static AnimatedValue tooltipAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
// game-related variables
|
||||
private static DisplayContainer displayContainer;
|
||||
|
||||
// This class should not be instantiated.
|
||||
private UI() {}
|
||||
|
||||
/**
|
||||
* Initializes UI data.
|
||||
*/
|
||||
public static void init(DisplayContainer displayContainer) {
|
||||
UI.displayContainer = displayContainer;
|
||||
backButton = new BackButton(displayContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all UI components by a delta interval.
|
||||
* @param delta the delta interval since the last call.
|
||||
@@ -92,15 +76,9 @@ public class UI {
|
||||
* Resets the necessary UI components upon entering a state.
|
||||
*/
|
||||
public static void enter() {
|
||||
backButton.resetHover();
|
||||
resetTooltip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the 'menu-back' MenuButton.
|
||||
*/
|
||||
public static BackButton getBackButton() { return backButton; }
|
||||
|
||||
/**
|
||||
* Draws a tab image and text centered at a location.
|
||||
* @param x the center x coordinate
|
||||
@@ -144,13 +122,13 @@ public class UI {
|
||||
else if (ratio >= 0.9f)
|
||||
xOffset = img.getWidth() * (1 - ((1 - ratio) * 10f));
|
||||
|
||||
img.drawCentered(displayContainer.width - img.getWidth() / 2f + xOffset, displayContainer.height / 2f);
|
||||
img.drawCentered(width - img.getWidth() / 2f + xOffset, height2);
|
||||
float barHeight = img.getHeight() * 0.9f;
|
||||
float volume = OPTION_MASTER_VOLUME.val / 100f;
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(
|
||||
displayContainer.width - (img.getWidth() * 0.368f) + xOffset,
|
||||
(displayContainer.height / 2f) - (img.getHeight() * 0.47f) + (barHeight * (1 - volume)),
|
||||
width - (img.getWidth() * 0.368f) + xOffset,
|
||||
height2 - (img.getHeight() * 0.47f) + (barHeight * (1 - volume)),
|
||||
img.getWidth() * 0.15f, barHeight * volume, 3
|
||||
);
|
||||
}
|
||||
@@ -209,8 +187,8 @@ public class UI {
|
||||
return;
|
||||
|
||||
// draw loading info
|
||||
float marginX = displayContainer.width * 0.02f, marginY = displayContainer.height * 0.02f;
|
||||
float lineY = displayContainer.height - marginY;
|
||||
float marginX = width * 0.02f, marginY = height * 0.02f;
|
||||
float lineY = height - marginY;
|
||||
int lineOffsetY = Fonts.MEDIUM.getLineHeight();
|
||||
if (OPTION_LOAD_VERBOSE.state) {
|
||||
// verbose: display percentages and file names
|
||||
@@ -223,7 +201,7 @@ public class UI {
|
||||
Fonts.MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Color.white);
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(marginX, lineY - (lineOffsetY / 2f),
|
||||
(displayContainer.width - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||
(width - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -247,7 +225,7 @@ public class UI {
|
||||
float unitBaseX, float unitBaseY, float unitWidth, float scrollAreaHeight,
|
||||
Color bgColor, Color scrollbarColor, boolean right
|
||||
) {
|
||||
float scrollbarWidth = displayContainer.width * 0.00347f;
|
||||
float scrollbarWidth = width * 0.00347f;
|
||||
float scrollbarHeight = scrollAreaHeight * lengthShown / totalLength;
|
||||
float offsetY = (scrollAreaHeight - scrollbarHeight) * (position / (totalLength - lengthShown));
|
||||
float scrollbarX = unitBaseX + unitWidth - ((right) ? scrollbarWidth : 0);
|
||||
@@ -283,7 +261,7 @@ public class UI {
|
||||
if (tooltipAlpha.getTime() == 0 || tooltip == null)
|
||||
return;
|
||||
|
||||
int margin = displayContainer.width / 100, textMarginX = 2;
|
||||
int margin = width / 100, textMarginX = 2;
|
||||
int offset = GameImage.CURSOR_MIDDLE.getImage().getWidth() / 2;
|
||||
int lineHeight = Fonts.SMALL.getLineHeight();
|
||||
int textWidth = textMarginX * 2, textHeight = lineHeight;
|
||||
@@ -303,12 +281,12 @@ public class UI {
|
||||
// get drawing coordinates
|
||||
int x = displayContainer.mouseX + offset;
|
||||
int y = displayContainer.mouseY + offset;
|
||||
if (x + textWidth > displayContainer.width - margin)
|
||||
x = displayContainer.width - margin - textWidth;
|
||||
if (x + textWidth > width - margin)
|
||||
x = width - margin - textWidth;
|
||||
else if (x < margin)
|
||||
x = margin;
|
||||
if (y + textHeight > displayContainer.height - margin)
|
||||
y = displayContainer.height - margin - textHeight;
|
||||
if (y + textHeight > height - margin)
|
||||
y = height - margin - textHeight;
|
||||
else if (y < margin)
|
||||
y = margin;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user