feat: Update viewport calculations in renderers for consistent height handling and improve map rendering logic
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -422,23 +422,32 @@ class AsciiRenderer extends CliRendererBackend<dynamic> {
|
||||
final int playerColor = ColorPalette.vga32Bit[10];
|
||||
final int facingColor = ColorPalette.vga32Bit[15];
|
||||
|
||||
if (_usesTerminalLayout) {
|
||||
_fillTerminalRect(
|
||||
projectionOffsetX,
|
||||
0,
|
||||
projectionWidth,
|
||||
_terminalPixelHeight,
|
||||
mapBgColor,
|
||||
);
|
||||
} else {
|
||||
_fillRect(0, 0, width, height, activeTheme.solid, mapBgColor);
|
||||
}
|
||||
|
||||
final int viewportY = 0;
|
||||
final int viewportX = _usesTerminalLayout ? projectionOffsetX : 0;
|
||||
final int viewportWidth = _usesTerminalLayout ? projectionWidth : width;
|
||||
final int viewportHeight = _usesTerminalLayout
|
||||
? _terminalPixelHeight
|
||||
: height;
|
||||
? projectionViewHeight
|
||||
: viewHeight;
|
||||
|
||||
if (_usesTerminalLayout) {
|
||||
_fillTerminalRect(
|
||||
viewportX,
|
||||
viewportY,
|
||||
viewportWidth,
|
||||
viewportHeight,
|
||||
mapBgColor,
|
||||
);
|
||||
} else {
|
||||
_fillRect(
|
||||
viewportX,
|
||||
viewportY,
|
||||
viewportWidth,
|
||||
viewportHeight,
|
||||
activeTheme.solid,
|
||||
mapBgColor,
|
||||
);
|
||||
}
|
||||
|
||||
final int viewportPadding = math.max(
|
||||
3,
|
||||
math.min(viewportWidth, viewportHeight) ~/ 24,
|
||||
@@ -458,7 +467,7 @@ class AsciiRenderer extends CliRendererBackend<dynamic> {
|
||||
final int mapPixelWidth = tileSize * 64;
|
||||
final int mapPixelHeight = tileSize * 64;
|
||||
final int mapStartX = viewportX + ((viewportWidth - mapPixelWidth) ~/ 2);
|
||||
final int mapStartY = (viewportHeight - mapPixelHeight) ~/ 2;
|
||||
final int mapStartY = viewportY + ((viewportHeight - mapPixelHeight) ~/ 2);
|
||||
|
||||
for (int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 64; x++) {
|
||||
|
||||
@@ -376,13 +376,14 @@ class SixelRenderer extends CliRendererBackend<String> {
|
||||
const int playerColor = 10;
|
||||
const int facingColor = 15;
|
||||
|
||||
for (int i = 0; i < _screen.length; i++) {
|
||||
_screen[i] = mapBgColor;
|
||||
}
|
||||
_fillMapRect(0, 0, width, viewHeight, mapBgColor);
|
||||
|
||||
final int viewportPadding = math.max(3, math.min(width, height) ~/ 24);
|
||||
final int viewportPadding = math.max(3, math.min(width, viewHeight) ~/ 24);
|
||||
final int availableWidth = math.max(1, width - (viewportPadding * 2));
|
||||
final int availableHeight = math.max(1, height - (viewportPadding * 2));
|
||||
final int availableHeight = math.max(
|
||||
1,
|
||||
viewHeight - (viewportPadding * 2),
|
||||
);
|
||||
final int tileSize = math.max(
|
||||
1,
|
||||
math.min(availableWidth, availableHeight) ~/ 64,
|
||||
@@ -390,7 +391,7 @@ class SixelRenderer extends CliRendererBackend<String> {
|
||||
final int mapPixelWidth = tileSize * 64;
|
||||
final int mapPixelHeight = tileSize * 64;
|
||||
final int mapStartX = (width - mapPixelWidth) ~/ 2;
|
||||
final int mapStartY = (height - mapPixelHeight) ~/ 2;
|
||||
final int mapStartY = (viewHeight - mapPixelHeight) ~/ 2;
|
||||
|
||||
for (int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 64; x++) {
|
||||
|
||||
@@ -156,11 +156,14 @@ class SoftwareRenderer extends RendererBackend<FrameBuffer> {
|
||||
final int playerColor = ColorPalette.vga32Bit[10];
|
||||
final int facingColor = ColorPalette.vga32Bit[15];
|
||||
|
||||
_fillMenuPanel(0, 0, width, height, mapBgColor);
|
||||
_fillMenuPanel(0, 0, width, viewHeight, mapBgColor);
|
||||
|
||||
final int viewportPadding = math.max(6, math.min(width, height) ~/ 24);
|
||||
final int viewportPadding = math.max(6, math.min(width, viewHeight) ~/ 24);
|
||||
final int availableWidth = math.max(1, width - (viewportPadding * 2));
|
||||
final int availableHeight = math.max(1, height - (viewportPadding * 2));
|
||||
final int availableHeight = math.max(
|
||||
1,
|
||||
viewHeight - (viewportPadding * 2),
|
||||
);
|
||||
final int tileSize = math.max(
|
||||
1,
|
||||
math.min(availableWidth, availableHeight) ~/ 64,
|
||||
@@ -168,7 +171,7 @@ class SoftwareRenderer extends RendererBackend<FrameBuffer> {
|
||||
final int mapPixelWidth = tileSize * 64;
|
||||
final int mapPixelHeight = tileSize * 64;
|
||||
final int mapStartX = (width - mapPixelWidth) ~/ 2;
|
||||
final int mapStartY = (height - mapPixelHeight) ~/ 2;
|
||||
final int mapStartY = (viewHeight - mapPixelHeight) ~/ 2;
|
||||
|
||||
for (int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 64; x++) {
|
||||
|
||||
Reference in New Issue
Block a user