Skip to content

Commit

Permalink
WIP: Improve Instrument and MusicVenueTool overlays.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeronica committed Mar 17, 2024
1 parent ea3250d commit 5041f53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ private float getVisibility(long milliseconds) {
/**
* Render an overlay instance.
*
* @param x screen right.
* @param y render top.
* @param instIndex render top.
* @param pPoseStack matrix.
* @param scaledWidth Gui Scaled Width.
* @param scaledHeight Gui Scaled Height.
* @param instIndex Instance index.
* @param pPoseStack matrix.
* @return true when rendering is done for this instance. Slide in, pause, slide out.
*/
@SuppressWarnings("deprecation")
public boolean render(int x, int y, int instIndex, MatrixStack pPoseStack) {
public boolean render(int scaledWidth, int scaledHeight, int instIndex, MatrixStack pPoseStack) {
long ms = Util.getMillis();
if (this.animationTime == -1L) {
this.animationTime = ms;
Expand All @@ -49,19 +49,19 @@ public boolean render(int x, int y, int instIndex, MatrixStack pPoseStack) {
}

IOverlayItem.Position position = overlayItemPosition.getPosition(this.overlayItem);
float ratio = Math.max(Math.min(Math.abs(overlayItemPosition.getPercent(this.overlayItem) / 100F), 1F), 0F);
float decimalPercent = Math.max(Math.min(Math.abs(overlayItemPosition.getPercent(this.overlayItem) / 100F), 1F), 0F);
float xPos;
float yPos = 0F + (y * ratio) - (y * ratio > this.overlayItem.totalHeight() ? this.overlayItem.totalHeight() : 0);
float yPos = ((scaledHeight - this.overlayItem.totalHeight()) * decimalPercent);

switch (position) {
case LEFT:
xPos = this.overlayItem.totalWidth() * (1 - this.getVisibility(ms)) + this.overlayItem.totalWidth() * (this.getVisibility(ms)) - this.overlayItem.totalWidth();
break;
case CENTER:
xPos = ((x * this.getVisibility(ms) * 0.5F)) + ((x * (1F - this.getVisibility(ms)) * 0.5F)) - this.overlayItem.totalWidth() * 0.5F * (this.getVisibility(ms));
xPos = ((scaledWidth * this.getVisibility(ms) * 0.5F)) + ((scaledWidth * (1F - this.getVisibility(ms)) * 0.5F)) - this.overlayItem.totalWidth() * 0.5F * (this.getVisibility(ms));
break;
case RIGHT:
xPos = (float) x - (float) this.overlayItem.totalWidth() * this.getVisibility(ms);
xPos = (float) scaledWidth - (float) this.overlayItem.totalWidth() * this.getVisibility(ms);
break;
default:
throw new IllegalStateException("Unexpected value: " + position);
Expand Down

0 comments on commit 5041f53

Please sign in to comment.