[SOLVED] Have NVL mode fit in a box

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

[SOLVED] Have NVL mode fit in a box

#1 Post by Kinmoku »

Hi all,

I'm using NVL mode for a second time so I'm a little confused. I want it to fit neatly in a box instead of take over the whole screen. The box is quite big and I've got the top, left and right edges working as I want, but the bottom seems to trail off no matter what I try. I want it to stop 280 pixels before the bottom of the screen.

Here's my GUI code:

Code: Select all

## NVL-Mode ####################################################################
##
## The NVL-mode screen displays the dialogue spoken by NVL-mode characters.

## The borders of the background of the NVL-mode background window.
define gui.nvl_borders = Borders(0, 32, 0, 280)

## The maximum number of NVL-mode entries Ren'Py will display. When more entries
## than this are to be show, the oldest entry will be removed.
define gui.nvl_list_length = 7

## The height of an NVL-mode entry. Set this to None to have the entries
## dynamically adjust height.
define gui.nvl_height = None

## The spacing between NVL-mode entries when gui.nvl_height is None, and between
## NVL-mode entries and an NVL-mode menu.
define gui.nvl_spacing = 0

## The position, width, and alignment of the label giving the name of the
## speaking character.
define gui.nvl_name_xpos = 565
define gui.nvl_name_ypos = 20
define gui.nvl_name_width = 225
define gui.nvl_name_xalign = 0.0

## The position, width, and alignment of the dialogue text.
define gui.nvl_text_xpos = 565
define gui.nvl_text_ypos = 60
define gui.nvl_text_width = 800
define gui.nvl_text_xalign = 0.0

## The position, width, and alignment of nvl_thought text (the text said by the
## nvl_narrator character.)
define gui.nvl_thought_xpos = 360
define gui.nvl_thought_ypos = 0
define gui.nvl_thought_width = 1170
define gui.nvl_thought_xalign = 0.0

## The position of nvl menu_buttons.
define gui.nvl_button_xpos = 960
define gui.nvl_button_xalign = 0.5
define gui.nvl_list_length is helpful if every line of dialogue is the same length, but they aren't in my case. It seems like 280 in my border settings is doing nothing :?

Also, does anyone know how to adjust the position of nvl mode menus? I want to put my menu in another box on the screen, not have it appear immediately beneath the dialogue.

Any ideas? Thanks in advance :)
Last edited by Kinmoku on Fri May 08, 2020 11:59 am, edited 1 time in total.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#2 Post by Kinmoku »

Just bumping this in case someone knows how to fix the bottom border issue?

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#3 Post by Kinmoku »

Here's a screenshot of what I'm trying to do (please ignore placeholder text!). Character images will eventually go in the boxes alongside the nvl mode.
borders.jpg
I thought my issue was with "define gui.nvl_list_length = 7" but setting it to None results in nvl entries loading off the screen. However, it says this is the "maximum number of nvl entries" but in my case it's defaulting to 7 every time, spilling out of the box if a long entry is written (like in the example).

I don't mind even having a scrollbar for this to work, but I'm sure there must be a solution :(

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Have NVL mode fit in a box

#4 Post by trooper6 »

I would think the thing to adjust is the borders of the screen, but the screen itself. The NVL Screens are defined in the screen.rpy file. There are two nvl screens:
screen nvl(dialogue, items=None)
screen nvl_dialogue(dialogue)

The first seems to be the screen used for menus and the second for dialogue. I'd try going there and put the size and location of those screens where you want them.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#5 Post by Kinmoku »

trooper6 wrote: Tue Apr 21, 2020 4:39 am The first seems to be the screen used for menus and the second for dialogue. I'd try going there and put the size and location of those screens where you want them.
Thanks Trooper. I've tried changing all kinds of properties: "yfill False", "ysize 800", "yminimum 800", "bottom_margin 300" etc. I've tried changing the nvl_window style and adding it directly to the screen but nothing has worked :( I also tried changing the window to vbox but that created a space of 800 pixels between nvl entries.

Code: Select all

screen nvl(dialogue, items=None):

    window: ## was window
        style "nvl_window"
        
        has vbox:
            spacing gui.nvl_spacing

        ## Displays dialogue in either a vpgrid or the vbox.
        if gui.nvl_height:

            vpgrid:
                cols 1
                yinitial 1.0

                use nvl_dialogue(dialogue)

        else:
            use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True, as it is above.
        for i in items:
            #ypos 800
            
            textbutton i.caption:
                action i.action
                style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0


screen nvl_dialogue(dialogue):

    for d in dialogue:

        window:
            id d.window_id

            fixed:
                yfit gui.nvl_height is None

                if d.who is not None:

                    text d.who:
                        id d.who_id

                text d.what:
                    id d.what_id


## This controls the maximum number of NVL-mode entries that can be displayed at
## once.
define config.nvl_list_length = gui.nvl_list_length

style nvl_window is default
style nvl_entry is default

style nvl_label is say_label
style nvl_dialogue is say_dialogue

style nvl_button is button
style nvl_button_text is button_text

style nvl_window:
    xfill True
    #yfill False
    ysize 800
    
    background None
    padding gui.nvl_borders.padding
    
    bottom_margin 300
I'm really stuck on this one. It really seems like nvl mode doesn't listen to anything other than gui.nvl_list_length :?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Have NVL mode fit in a box

#6 Post by Alex »

Kinmoku wrote: Tue Apr 21, 2020 4:27 am ...I don't mind even having a scrollbar for this to work, but I'm sure there must be a solution :(
Try to put the nvl box with dialogues inside a viewport - viewtopic.php?f=8&t=23434#p293323

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#7 Post by Kinmoku »

Alex wrote: Tue Apr 21, 2020 4:15 pm Try to put the nvl box with dialogues inside a viewport - viewtopic.php?f=8&t=23434#p293323
Oh cool :) Viewport works just like I want. Your previous post is just what I was looking for!

However, I have a strange issue where I have to click several times (or skip) to progress the dialogue along. Once it does, though, it's fine.

But it has also made the nvl menu put items on top of one another.

Here's my code:

Code: Select all

screen nvl(dialogue, items=None):

    window:
        style "nvl_window"
        
        viewport id "vp":
            draggable True
            yadjustment ui.adjustment (value=9999, range=9999)   # err... works, but...
       
            vbox:
                if gui.nvl_height:

                    vpgrid:
                        cols 1
                        yinitial 1.0

                        use nvl_dialogue(dialogue)

                else:
                    use nvl_dialogue(dialogue)

        ## Displays the menu, if given. The menu may be displayed incorrectly if
        ## config.narrator_menu is set to True, as it is above.
        for i in items:
            vbox: # I added this for positioning, but it still shows menu choices on top of one another without it 
                ypos 800 # I added this for positioning, but it still shows menu choices on top of one another without it 
                textbutton i.caption:
                    action i.action
                    style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0
I'm not quite sure what I've done wrong, but I'm struggling to understand this nvl screen :(

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Have NVL mode fit in a box

#8 Post by Alex »

Kinmoku wrote: Wed Apr 22, 2020 4:49 am ...
Try this sample

Code: Select all

screen nvl(dialogue, items=None):
    
    frame:
        pos (400, 100)
        
        side "c":
            area (0, 0, 480, 500)

            viewport id "vp":
                draggable True
                yinitial 1.0
                 

                vbox:
                    spacing gui.nvl_spacing
                    
                    use nvl_dialogue(dialogue)

                     
    ## Displays the menu, if given. The menu may be displayed incorrectly if
    ## config.narrator_menu is set to True, as it is above.
    hbox:
        pos(404, 610)
        for i in items:

            textbutton i.caption:
                action i.action
                style "nvl_button"

Code: Select all

label start:
    window auto
    "..."
    s "Line 1"
    e "Line 2"
    s "Line 3"
    e "Line 4"
    s "Line 5"
    e "Line 6"
    s "Line 7"
    e "Line 8"
    s "Line 9"
    menu:
        "Choice 1":
            "Ch 1"
        "Choice 2":
            "Ch 2"
    e "Line 10"
    s "Line 11"
    e "Line 12"
    s "Line 13"
    e "Line 14"
    s "Line 15"
    menu:
        "Choice 3":
            "Ch 3"
        "Choice 4":
            "Ch 4"
    e "Line 16"
    s "Line 17"
    e "Line 18"
    s "Line 19"

    return

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#9 Post by Kinmoku »

Alex wrote: Thu Apr 23, 2020 3:47 pm Try this sample
Hey, sorry it took me a while to try this out. It creates the frame but none of the dialogue shows, however, if I click enough times, the menu then appears as desired...So the dialogue is playing, it just cannot be seen :( The text is white on black so I don't think it's hiding.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#10 Post by Kinmoku »

Ah, I needed to change yinitial for it to work.

However, it still had an issue which meant that the viewport didn't progress the dialogue when clicked on (clicking off it was fine, but because it's so big, it felt like the game was broken). I added a button for the shape/ position of the viewport to help this, but when the NVL menu appears, the button is still there, meaning it returns from the menu when clicked on and the player doesn't get to make a choice.

I'm unsure what the best solution is here...Having a separate screen for the NVL menu may help but I'm not sure how to make this without it breaking what I have.

Here's my code:

Code: Select all

screen nvl(dialogue, items=None):

    frame:
        pos (540, 30)
        
        side "c":
            area (0, 0, 844, 780)

            viewport id "vp":
                draggable True
                #yinitial 1.0
                yadjustment ui.adjustment (value=9999, range=9999)   # err... works, but...

                vbox:
                    spacing gui.nvl_spacing
                    use nvl_dialogue(dialogue)
                    
    button:
        background None
        xsize 844
        ysize 780
        xpos 540
        ypos 30
        action Return()
    
    vbox:
        pos(0, 850)
        for i in items:
                textbutton i.caption:
                    action i.action
                    style "nvl_button"

    add SideImage() xalign 0.0 yalign 1.0

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Have NVL mode fit in a box

#11 Post by Alex »

Kinmoku wrote: Tue May 05, 2020 4:49 am ...
Try

Code: Select all

            viewport id "vp":
                #draggable True
                yinitial 1.0
This might be that game isn't progress 'cause it treats mouse click over the viewport as an attempt to drag it.

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Have NVL mode fit in a box

#12 Post by Kinmoku »

Alex wrote: Thu May 07, 2020 1:54 pm
Kinmoku wrote: Tue May 05, 2020 4:49 am ...
Try

Code: Select all

            viewport id "vp":
                #draggable True
                yinitial 1.0
This might be that game isn't progress 'cause it treats mouse click over the viewport as an attempt to drag it.
Yes this works. It means I lose draggable, which is unfortunate, but I'm going for a retro-looking UI anyway, so I'll try adding a scrollbar instead. Thanks for your help :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]