Fix ADMDRAW targetting

This commit is contained in:
2026-08-30 23:33:33 +00:00
parent 3a576b79b4
commit a3c4b95379
15 changed files with 1381 additions and 212 deletions
@@ -221,8 +221,8 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
int ox = getRenderOffsetX();
int oy = getRenderOffsetY();
ScreenBuffer sb = client.getScreenBuffer();
int gridW = sb.getDisplayCols() * cellWidth;
int gridH = sb.getDisplayRows() * cellHeight;
int gridW = (sb != null ? sb.getDisplayCols() : 80) * cellWidth;
int gridH = (sb != null ? sb.getDisplayRows() : 24) * cellHeight;
int gWidth = client.getGraphicsPlane().getCanvasWidth();
int gHeight = client.getGraphicsPlane().getCanvasHeight();
int px = (gridW > 0 && gWidth > 0) ? (int) Math.round((double) (e.getX() - ox) * gWidth / gridW) : (e.getX() - ox);
@@ -253,6 +253,7 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
if (isGraphic) {
clearSelection();
sb.setCursorAddress(clickAddr);
int gridW = displayCols * cellWidth;
int gridH = displayRows * cellHeight;
int gWidth = client.getGraphicsPlane().getCanvasWidth();
@@ -995,11 +996,17 @@ public class TerminalPanel extends JPanel implements java.awt.print.Printable {
double curX = x;
double curY = y;
if (dir == GocaConstants.CD_TB) {
curY += ch;
} else if (dir == GocaConstants.CD_RL) {
curX -= cw;
}
for (int i = 0; i < text.length(); i++) {
String s = text.substring(i, i + 1);
int charW = fm.stringWidth(s);
int drawX = (int) Math.round(curX + Math.max(0, (cw - charW) / 2.0));
int drawY = (int) Math.round(curY + ascent + Math.max(0, (ch - fm.getHeight()) / 2.0));
int drawY = (int) Math.round(curY);
g2.drawString(s, drawX, drawY);
switch (dir) {