Still struggling with my viewport to show the bottom portion of the iewport first.
Alex wrote:Maybe reshow screen after message was added?
Tried that, didn't work.
The viewport content updates when I modify the list that controls it, but the new message is at the bottom, hidden. I want it to be visible.
My current screen code is:
Code: Select all
screen comms(correspondant,messages):
add "gui/tab.png"
side "c r":
area (268,98,744,486)
viewport id "com":
draggable False
mousewheel True
yinitial 1.0
vbox:
xsize 730
style_prefix "comm"
for message in messages:
if message[0] == "laura":
hbox:
xalign 1.0
frame:
background Solid("#00ffaa")
has vbox
label "Me" xalign 1.0 text_color "#006644"
text message[1]
add "comm laura"
else:
$ comm_image = "comm " + message[0]
hbox:
add comm_image
frame:
xalign 0.0
background Solid("#cc99ff")
has vbox
label message[0] text_color "#6600cc"
text message[1]
vbar value YScrollValue("com"):
unscrollable "hide"
I show the screen for the first time with
Code: Select all
show screen comms("John",messages_john)
And then I update viewport content with this function and this instruction
Code: Select all
init python:
def new_message(liste_messages,message):
liste_messages.append(message)
Code: Select all
$ new_message(messages_john,("laura",_("What do you know about this new security thing?")))
Viewport content is updated without re-showing the screen, but my new message is hidden at the bottom, I have to scroll to make it appear (which is not trivial for the player...)
I thought about manipulating the viewport position by manipulating the scrollbar.
So I first added this to my function definition
Code: Select all
def new_message(liste_messages,message):
liste_messages.append(message)
YScrollValue("com") = 1.0
which resulted in an error, because, as I discovered, YScrollValue is not a variable but a BarValue object.
So I tried to manipulate that BarValue object like that
Code: Select all
def new_message(liste_messages,message):
liste_messages.append(message)
YScrollValue("com").get_adjustment().change(1.0)
Which didn't work either, because I discovered that 1.0 doesn't represent a proportion but more an absolute value, and that value changes all the time.
So I thought range of the bar would represent the maximum, and I tried that
Code: Select all
def new_message(liste_messages,message):
liste_messages.append(message)
YScrollValue("com").get_adjustment().change(YScrollValue("com").get_adjustment().range)
which still didn't work. Last message still appear hidden, and I have to scroll to make it appear. Plus I randomly bump on this error, depending on how I moved the scrollbar inside the game
Code: Select all
While running game code:
File "game/script.rpy", line 366, in script
$ new_message(messages_john,("laura",_("OK, love dates!")))
File "game/script.rpy", line 366, in <module>
$ new_message(messages_john,("laura",_("OK, love dates!")))
File "game/script.rpy", line 78, in new_message
YScrollValue("com").get_adjustment().change(0.0)
File "renpy/common/00barvalues.rpy", line 475, in get_adjustment
raise Exception("The displayable with id %r is not declared, or not a viewport." % self.viewport)
Exception: The displayable with id u'com' is not declared, or not a viewport.
At that point I feel a little depressed and I don't see what to try next.
I can't wrap my head around that BarValue object and ui.adjusment() thing.
Is there a specialist around here that might explain me how all that work?