Skip to content

Commit

Permalink
Java client: Adjust emoji position for scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Oct 31, 2023
1 parent 96f0b52 commit 2a20cad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/games/stendhal/client/gui/j2d/RemovableSprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.awt.Graphics;
import java.awt.Rectangle;

import games.stendhal.client.GameScreen;
import games.stendhal.client.GameScreenSpriteHelper;
import games.stendhal.client.entity.Entity;
import games.stendhal.client.sprite.Sprite;
Expand Down Expand Up @@ -137,8 +138,15 @@ private void drawAttached(final Graphics g) {
public void drawEmoji(final Graphics g) {
final int svx = GameScreenSpriteHelper.getScreenViewX();
final int svy = GameScreenSpriteHelper.getScreenViewY();
final int sx = GameScreenSpriteHelper.convertWorldToPixelUnits(owner.getX());
final int sy = GameScreenSpriteHelper.convertWorldToPixelUnits(owner.getY());
int sx;
int sy;
if (GameScreen.get().isScaled()) {
sx = GameScreenSpriteHelper.convertWorldXToScaledScreen(owner.getX());
sy = GameScreenSpriteHelper.convertWorldYToScaledScreen(owner.getY());
} else {
sx = GameScreenSpriteHelper.convertWorldToPixelUnits(owner.getX());
sy = GameScreenSpriteHelper.convertWorldToPixelUnits(owner.getY());
}
sprite.draw(g, sx - svx - 16, sy - svy - 32);
}

Expand Down

0 comments on commit 2a20cad

Please sign in to comment.