-
-
Save methanoliver/cb6ae08d432d9395cff65975733599ab to your computer and use it in GitHub Desktop.
Two-column NVL mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a script.rpy meant to be dumped into a default project, | |
# so we're redefining our screens and styles in an init 20 block | |
# to ensure they override the defaults. | |
init 20: | |
# Basic setup to have two windows with a column each | |
# and clean off the insensible defaults. | |
# None of these lines are actually important, they're there only | |
# to help you see how it works. | |
define gui.nvl_height = None | |
define gui.nvl_text_xpos = 0.0 | |
define gui.nvl_text_ypos = 0 | |
define gui.nvl_text_xalign = 0 | |
define gui.nvl_thought_xpos = 0 | |
define gui.nvl_thought_ypos = 0 | |
define gui.nvl_thought_width = 512 | |
define gui.nvl_thought_xalign = 0.0 | |
define narrator = nvl_narrator | |
# Redefine our NVL screen to split things into two columns: | |
screen nvl(dialogue, items=None): | |
# The basis of the trick: | |
# NVL screen gets "dialogue", a list of objects containing information about the say statements | |
# and their display properties acquired from Character objects. | |
# We scan what is actually said, and filter them into two bins: | |
# for the first and for the second column, based on the presence of a tag | |
# inside the text itself: | |
python: | |
pages = {1:[], 2:[]} | |
for x in dialogue: | |
if "{#right}" in x.what: | |
pages[2].append(x) | |
else: | |
pages[1].append(x) | |
# Then we use a window (with an explicitly set style | |
# we can later define to put the window where it needs to be) | |
# to display one of the columns. | |
window: | |
style "nvl_window_left" | |
has vbox: | |
spacing gui.nvl_spacing | |
# We call the nvl_dialogue to actually display a column, | |
# but instead of "dialogue" we give it one of our sorted bins. | |
use nvl_dialogue(pages[1]) | |
# Then do the same with the other column. | |
window: | |
style "nvl_window_right" | |
has vbox: | |
spacing gui.nvl_spacing | |
# The other column gets the oher bin instead. | |
use nvl_dialogue(pages[2]) | |
## We also stick the NVL menu in this column, because it needs to be | |
## somewhere, or the menu won't work, but if you never use the nvl menu, | |
## you can just excise this section. | |
for i in items: | |
textbutton i.caption: | |
action i.action | |
style "nvl_button" | |
style nvl_window is default: | |
margin (10, 10) | |
padding (20, 16, 20, 16) | |
background Solid("#000") | |
style nvl_window_right is nvl_window: | |
xalign 1.0 | |
xsize 512 | |
yfill True | |
style nvl_window_left is nvl_window: | |
xalign 0.0 | |
xsize 512 | |
yfill True | |
style nvl_dialogue: | |
xpos gui.nvl_text_xpos | |
xanchor gui.nvl_text_xalign | |
ypos gui.nvl_text_ypos | |
xfill True | |
min_width 512 | |
text_align gui.nvl_text_xalign | |
style nvl_thought is nvl_dialogue | |
label start: | |
scene bg room | |
"Wanted to have an NVL-mode book? Here's how." | |
"This goes into the left column." | |
"{#right}This goes into the right column." | |
"The fun part is that you can actually fill columns in any order." | |
"{#right}But normally you would stay on the first page until it filled, | |
and then write the lines for the second column." | |
"{#right}You still need to manually decide what goes into which column and | |
when to nvl_clear, but I'd wager you want this control anyway." | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment