nodes/layout.pyΒΆ
Part of GDQuest Open RPG.
1"""Viewport lookup shared by every screen-space overlay in the port."""
2
3from __future__ import annotations
4
5from .settings import HEIGHT, WIDTH
6
7
8def viewport_size(node) -> tuple[float, float]:
9 """Live viewport size in pixels (design resolution when off-tree).
10
11 The dialogue panel, battle HUD, fade overlay and controls strip all lay
12 themselves out from this rather than the fixed ``WIDTH``/``HEIGHT``
13 constants, so the port stays correct when the desktop window or the
14 browser canvas is resized.
15 """
16 tree = node.tree
17 if tree is None:
18 return float(WIDTH), float(HEIGHT)
19 w, h = tree.screen_size
20 return float(w), float(h)