Page 1 of 1

Button which opens up a menu screen

Posted: Mon May 18, 2020 11:12 am
by Kinmoku
Hi all,

I'm trying to create a button which opens up a choice menu screen (It's to comment on a picture in a social media-like interface).

I've been reading this post: viewtopic.php?t=44767 , though I am unsure how to proceed.

The screen which has the button is below:

Code: Select all

screen pic_violet(log):
    zorder 0
    modal True 
    tag sharkmenu
    use shark_interface
    
    add "images/menu_on.png" xpos 0 ypos 344
    
    imagebutton idle "images/back_button.png" clicked [Hide("pic_violet"), Show("feudal_fantasy_community")] xpos 16 ypos 960 focus_mask True
    
    imagebutton idle "images/post_button.png" action [Show("write_post"), choice_items1]  xpos 1700 ypos 16 focus_mask True
    
    text _("Feudal Fantasy Community") color "#000000" xpos 30 ypos 16
    
    vbox:
        xpos 334
        ypos 144
        spacing 20
        add "violet"
    
    frame:
        background None
        use chat_log2(log)
        
        
screen write_post: ## the custom choice screen I want to use here
    add "images/write_post.png" xpos 454 ypos 190
    
    text _("Write Post") color "#000000" xpos 890 ypos 202
    
    vbox:
        xpos 660
        ypos 350
        
        label "Select:"

        vbox:
            #for i in items:
            textbutton i.caption action i.action style "black_text" ## I'm unsure what to put here.
        
    hbox:
        xpos 662
        ypos 732
        
        spacing 40
        
        button:
            action Hide("write_post")
            xysize (290, 98)
            background "confirm_button"
            text _("Cancel") style "black_text" xpos 78 ypos 20
        
        
My script shows up as follows:

Code: Select all

label pic_violet:
    
    show screen pic_violet(vhslog)
    
    $ vhslog.add_chat(msg="Wow :O", nick="Wolfie", avatar="images/avatars/wolfie.png", posttime="1 day ago") ## previous comments you can read
    $ vhslog.add_chat(msg="OMG you can draw so much better than me XD", nick="Markus", avatar="images/avatars/markus.png", posttime="1 day ago")
    $ vhslog.add_chat(msg="Haha ;-)", nick="Lindsay222", avatar="images/avatars/lindsay.png", posttime="1 day ago")
    
    $ choice_items1 = ["Wow!", "I love it!", "Meh"] # I want these choice to show when/if the player clicks the post button
    
    pause
How do I get this to work?

Re: Button which opens up a menu screen

Posted: Mon May 18, 2020 11:50 pm
by hell_oh_world
maybe use the screen write_post directly instead of setting the post messages via variable...

Code: Select all

screen write_post(items): ## the custom choice screen I want to use here
    add "images/write_post.png" xpos 454 ypos 190
    
    text _("Write Post") color "#000000" xpos 890 ypos 202

    default picked = None
    
    if not picked:
        vbox:
            xpos 660
            ypos 350
        
            label "Select:"

            vbox:
                for i in items:
                    textbutton i:
                        action SetScreenVariable("picked", i)
                        style "black_text"

    else picked:
        hbox:
            xpos 662
            ypos 732
        
            spacing 40
        
            vbox:
                text _("Send '[picked]' as the post message?")
                hbox:
                    textbutton "Yes" action [Function(vhslog.add_chat, msg=picked, nick="Markus", avatar="images/avatars/markus.png", posttime="Just now"), Hide("write_post")]
                    textbutton "No" action SetScreenVariable("picked", None)

label pic_violet:
    
    show screen pic_violet(vhslog)
    
    $ vhslog.add_chat(msg="Wow :O", nick="Wolfie", avatar="images/avatars/wolfie.png", posttime="1 day ago") ## previous comments you can read
    $ vhslog.add_chat(msg="OMG you can draw so much better than me XD", nick="Markus", avatar="images/avatars/markus.png", posttime="1 day ago")
    $ vhslog.add_chat(msg="Haha ;-)", nick="Lindsay222", avatar="images/avatars/lindsay.png", posttime="1 day ago")
    
    show screen write_post(["Wow!", "I love it!", "Meh"])
    
    pause

Re: Button which opens up a menu screen

Posted: Tue May 19, 2020 4:02 am
by Kinmoku
hell_oh_world wrote:
Mon May 18, 2020 11:50 pm
maybe use the screen write_post directly instead of setting the post messages via variable...

Code: Select all

screen write_post(items): ## the custom choice screen I want to use here
    add "images/write_post.png" xpos 454 ypos 190
    
    text _("Write Post") color "#000000" xpos 890 ypos 202

    default picked = None
    
    if not picked:
        vbox:
            xpos 660
            ypos 350
        
            label "Select:"

            vbox:
                for i in items:
                    textbutton i:
                        action SetScreenVariable("picked", i)
                        style "black_text"

    else picked:
        hbox:
            xpos 662
            ypos 732
        
            spacing 40
        
            vbox:
                text _("Send '[picked]' as the post message?")
                hbox:
                    textbutton "Yes" action [Function(vhslog.add_chat, msg=picked, nick="Markus", avatar="images/avatars/markus.png", posttime="Just now"), Hide("write_post")]
                    textbutton "No" action SetScreenVariable("picked", None)

label pic_violet:
    
    show screen pic_violet(vhslog)
    
    $ vhslog.add_chat(msg="Wow :O", nick="Wolfie", avatar="images/avatars/wolfie.png", posttime="1 day ago") ## previous comments you can read
    $ vhslog.add_chat(msg="OMG you can draw so much better than me XD", nick="Markus", avatar="images/avatars/markus.png", posttime="1 day ago")
    $ vhslog.add_chat(msg="Haha ;-)", nick="Lindsay222", avatar="images/avatars/lindsay.png", posttime="1 day ago")
    
    show screen write_post(["Wow!", "I love it!", "Meh"])
    
    pause
Thank you, though I really need a button instead of "show screen write_post(["Wow!", "I love it!", "Meh"])" coming up automatically.

I thought maybe I could jump to a label with this code using the button, but even when I set it all up, the choices/ items are not there :(

Here's my code. I made a few changes:

Code: Select all

screen write_post(items):
    add "images/write_post.png" xpos 454 ypos 190
    
    text _("Write Post") color "#000000" xpos 890 ypos 202
    
    default picked = None
    
    if not picked:
        vbox:
            xpos 660
            ypos 350
        
            label "Select:"

            vbox:
                for i in items:
                    textbutton i:
                        action SetScreenVariable("picked", i)
                        style "red_text" ## changed this to ensure I can see it on the background
                        
    else:# picked: didn't work
        hbox:
            xpos 662
            ypos 732
        
            spacing 40
        
            vbox:
                text _("Send '[picked]' as the post message?")
                hbox:
                    textbutton "Yes" action [Function(vhslog.add_chat, msg=picked, nick="Markus", avatar="images/avatars/markus.png", posttime="Just now"), Hide("write_post")] style "red_text"
                    textbutton "No" action SetScreenVariable("picked", None) style "red_text"
                    
                    
                    
screen pic_violet(log):
    zorder 0
    modal True 
    tag sharkmenu
    use shark_interface
    
    add "images/menu_on.png" xpos 0 ypos 344
    
    imagebutton idle "images/back_button.png" clicked [Hide("pic_violet"), Show("feudal_fantasy_community")] xpos 16 ypos 960 focus_mask True
    
    imagebutton idle "images/post_button.png" action Jump("vhs_post") xpos 1700 ypos 16 focus_mask True
    text _("Post") color "#000000" xpos 1780 ypos 30
    
    text _("Feudal Fantasy Community") color "#000000" xpos 30 ypos 16
    
    vbox:
        xpos 334
        ypos 144
        spacing 20
        add "violet"
        text "377 people liked this."
    
    frame:
        background None
        use chat_log2(log)
In script:

Code: Select all

    
label pic_violet_hanzo_sword:
    
    show screen pic_violet_hanzo_sword(vhslog)
    
    $ vhslog.add_chat(msg="Wow :O", nick="Wolfie", avatar="images/avatars/wolfie.png", posttime="1 day ago")
    $ vhslog.add_chat(msg="OMG you can draw so much better than me XD", nick="Markus", avatar="images/avatars/markus.png", posttime="1 day ago")
    $ vhslog.add_chat(msg="Haha ;-)", nick="Lindsay222", avatar="images/avatars/lindsay.png", posttime="1 day ago")

    pause
    
    
label vhs_post:
    show screen write_post(["Wow!", "I love it!", "Meh"])
        
    pause