Refactor menu rendering and improve projection sampling
- Updated AsciiRasterizer to support game and episode selection menus with improved layout and cursor handling. - Enhanced SixelRasterizer and SoftwareRasterizer to modularize menu drawing logic for game and episode selection. - Introduced new methods for drawing menus and applying fade effects across rasterizers. - Adjusted wall texture sampling in Rasterizer to anchor to projection height center for consistent rendering. - Added tests for wall texture sampling behavior to ensure legacy compatibility and new functionality. - Modified Flutter audio adapter to use nullable access for active game and adjusted game selection logic in the main class. - Cleaned up input handling in Wolf3dFlutterInput by removing unused menu tap variables. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -51,28 +51,9 @@ class _GameScreenState extends State<GameScreen> {
|
||||
child: Scaffold(
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final viewportRect = _menuViewportRect(
|
||||
Size(constraints.maxWidth, constraints.maxHeight),
|
||||
);
|
||||
|
||||
return Listener(
|
||||
onPointerDown: (event) {
|
||||
widget.wolf3d.input.onPointerDown(event);
|
||||
if (_engine.difficulty == null &&
|
||||
viewportRect.width > 0 &&
|
||||
viewportRect.height > 0 &&
|
||||
viewportRect.contains(event.localPosition)) {
|
||||
final normalizedX =
|
||||
(event.localPosition.dx - viewportRect.left) /
|
||||
viewportRect.width;
|
||||
final normalizedY =
|
||||
(event.localPosition.dy - viewportRect.top) /
|
||||
viewportRect.height;
|
||||
widget.wolf3d.input.queueMenuTap(
|
||||
x: normalizedX,
|
||||
y: normalizedY,
|
||||
);
|
||||
}
|
||||
},
|
||||
onPointerUp: widget.wolf3d.input.onPointerUp,
|
||||
onPointerMove: widget.wolf3d.input.onPointerMove,
|
||||
@@ -148,32 +129,4 @@ class _GameScreenState extends State<GameScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Rect _menuViewportRect(Size availableSize) {
|
||||
if (availableSize.width <= 0 || availableSize.height <= 0) {
|
||||
return Rect.zero;
|
||||
}
|
||||
|
||||
const double aspect = 4 / 3;
|
||||
final double outerPadding = _useAsciiMode ? 0.0 : 16.0;
|
||||
final double maxWidth = (availableSize.width - (outerPadding * 2)).clamp(
|
||||
1.0,
|
||||
double.infinity,
|
||||
);
|
||||
final double maxHeight = (availableSize.height - (outerPadding * 2)).clamp(
|
||||
1.0,
|
||||
double.infinity,
|
||||
);
|
||||
|
||||
double viewportWidth = maxWidth;
|
||||
double viewportHeight = viewportWidth / aspect;
|
||||
if (viewportHeight > maxHeight) {
|
||||
viewportHeight = maxHeight;
|
||||
viewportWidth = viewportHeight * aspect;
|
||||
}
|
||||
|
||||
final double left = (availableSize.width - viewportWidth) / 2;
|
||||
final double top = (availableSize.height - viewportHeight) / 2;
|
||||
return Rect.fromLTWH(left, top, viewportWidth, viewportHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user