4

Renpy 使用大量 python 和定制代码,以便使用say statement.

在遇到了 inside renpy 的一些问题nvl mode后,我发现有必要知道屏幕上将显示多少行(考虑到字体大小,当然还有文本窗口的大小)。

所以我的问题

由于我在文档中没有找到任何与此相关的内容,我想知道是否有任何命令或其他可能性来预先计算要显示的文本的高度?

4

1 回答 1

1

get_virtual_layout()class Textin的一部分text.py

我复制了这个text.py

# Find the virtual-resolution layout.
virtual_layout = self.get_virtual_layout()
# The laid-out size of this Text.
vw, vh = virtual_layout.size

我认为这看起来很有希望。

使用虚拟文本大小(宽度、高度),您可以使用文本窗口大小(宽度、高度)来计算文本行。

pseudo code:
lines = int(vw/text_window.width)
#the text height would then be
text_height_needed = int(lines*vh)
# does it fit in completely
complete_text_in_window = text_window.height >= text_height_needed
# visible lines
visible_lines = int(text_window.height/vh)

此外,值得深入了解text.py(例如def render(self, width, height, st, at)),以便了解virtual_layout.

我希望它以某种方式有所帮助。

更新

def render(...)初始化虚拟布局,因此get_virtual_layout()不再是 None ,而是表示Layout()具有缩放宽度和高度的实例。

于 2016-12-23T06:58:09.083 回答