[SOLVED] SCREEN selections

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
Bruni Multimedia
Regular
Posts: 114
Joined: Mon May 15, 2017 12:23 pm
Projects: Yomi Alliance
Organization: Bruni Multimedia
itch: brunimultimedia
Contact:

[SOLVED] SCREEN selections

#1 Post by Bruni Multimedia »

Hello. I'll try to expose my issue here:

I have the following screen, which highlights itself when hovering on a selection

Image

Clicking on it shows a list of personnel of the given selection, however "selection #1" is no longer highlighted

Image

And if I click on a name on the list (to show a third screen), ALL selections from column #2 are highlighted (and I wish just one of them to be) and no choice from column #1 is:

Image

This is the code for the above screens:

Code: Select all

screen reftrai:
    imagemap:
        ground "gui/reftrai_inactive.png"
        idle "gui/reftrai_inactive.png"
        hover "gui/reftrai_active.png"
        selected_idle "gui/reftrai_inactive.png"
        selected_hover "gui/reftrai_active.png"
        if selezione == "dr":
            selected_idle "gui/reftrai_inactive.png"
        hotspot (6, 51, 350, 85) action ShowMenu("reftrai_selection", selezione = "dr")
        hotspot (6, 145, 350, 85) action ShowMenu("reftrai_selection", selezione = "nu")
        hotspot (6, 234, 350, 85) action ShowMenu("reftrai_selection", selezione = "mw")
        hotspot (6, 317, 350, 85) action ShowMenu("reftrai_selection", selezione = "ch")
        hotspot (6, 401, 350, 85) action ShowMenu("reftrai_selection", selezione = "te")
        hotspot (6, 484, 350, 85) action ShowMenu("reftrai_selection", selezione = "ad")

        hotspot (1027, 640, 252, 56) action Return()

        transclude

screen reftrai_selection(selezione):
    use reftrai
    frame:
        side ("c r"):
            area (424, 68, 338, 504)
            viewport id "my_scrollbar":
                draggable True mousewheel True

                vbox:
                    xpos 0.52
                    ypos 0.35
                    xmaximum 300
                    if selezione == "dr":
                        if dr1_hired == True:
                            textbutton "{b}[DR1_name]" action Show("courses", who="dr",number="1",selezione="dr") text_style "codmedcond_button_text"
                        if dr2_hired == True:
                            textbutton "{b}[DR2_name]" action Show("courses", who="dr",number="2",selezione="dr") text_style "codmedcond_button_text"
                        if dr3_hired == True:
                            textbutton "{b}[DR3_name]" action Show("courses", who="dr",number="3",selezione="dr") text_style "codmedcond_button_text"
                        if dr1_hired == True or dr2_hired == True or dr3_hired == True:
                            textbutton "Every Doctor" action Show("courses", who="dr",number="4",selezione="dr") text_style "codmedcond_button_text"
                    if selezione == "mw":
                        if mw1_hired == True:
                            textbutton "{b}[MW1_name]" action Show("courses", who="mw",number="1",selezione="mw") text_style "codmedcond_button_text"
                        if mw2_hired == True:
                            textbutton "{b}[MW2_name]" action Show("courses", who="mw",number="2",selezione="mw") text_style "codmedcond_button_text"
                        if mw3_hired == True:
                            textbutton "{b}[MW3_name]" action Show("courses", who="mw",number="3",selezione="mw") text_style "codmedcond_button_text"
                        if mw1_hired == True or mw2_hired == True or mw3_hired == True:
                            textbutton "Every Midwife" action Show("courses", who="mw",number="4",selezione="mw") text_style "codmedcond_button_text"
                    if selezione == "nu":
                        if nu1_hired == True:
                            textbutton "{b}[NU1_name]" action Show("courses", who="nu",number="1",selezione="nu") text_style "codmedcond_button_text"
                        if nu2_hired == True:
                            textbutton "{b}[NU2_name]" action Show("courses", who="nu",number="2",selezione="nu") text_style "codmedcond_button_text"
                        if nu3_hired == True:
                            textbutton "{b}[NU3_name]" action Show("courses", who="nu",number="3",selezione="nu") text_style "codmedcond_button_text"
                        if nu1_hired == True or nu2_hired == True or nu3_hired == True:
                            textbutton "Every Nurse" action Show("courses", who="nu",number="4",selezione="nu") text_style "codmedcond_button_text"
                    if selezione == "ch":
                        if ch1_hired == True:
                            textbutton "{b}[CH1_name]" action Show("courses", who="ch",number="1",selezione="ch") text_style "codmedcond_button_text"
                        if ch2_hired == True:
                            textbutton "{b}[CH2_name]" action Show("courses", who="ch",number="2",selezione="ch") text_style "codmedcond_button_text"
                        if ch3_hired == True:
                            textbutton "{b}[CH3_name]" action Show("courses", who="ch",number="3",selezione="ch") text_style "codmedcond_button_text"
                        if ch1_hired == True or ch2_hired == True or ch3_hired == True:
                            textbutton "Every Chief of Staff" action Show("courses", who="ch",number="4",selezione="ch") text_style "codmedcond_button_text"
                    if selezione == "te":
                        if te1_hired == True:
                            textbutton "{b}[TE1_name]" action Show("courses", who="te",number="1",selezione="te") text_style "codmedcond_button_text"
                        if te2_hired == True:
                            textbutton "{b}[TE2_name]" action Show("courses", who="te",number="2",selezione="te") text_style "codmedcond_button_text"
                        if te3_hired == True:
                            textbutton "{b}[TE3_name]" action Show("courses", who="te",number="3",selezione="te") text_style "codmedcond_button_text"
                        if te1_hired == True or te2_hired == True or te3_hired == True:
                            textbutton "Every Technician" action Show("courses", who="te",number="4",selezione="te") text_style "codmedcond_button_text"
                    if selezione == "ad":
                        if ad1_hired == True:
                            textbutton "{b}[AD1_name]" action Show("courses", who="ad",number="1",selezione="ad") text_style "codmedcond_button_text"
                        if ad2_hired == True:
                            textbutton "{b}[AD2_name]" action Show("courses", who="ad",number="2",selezione="ad") text_style "codmedcond_button_text"
                        if ad3_hired == True:
                            textbutton "{b}[AD3_name]" action Show("courses", who="ad",number="3",selezione="ad") text_style "codmedcond_button_text"
                        if ad1_hired == True or ad2_hired == True or ad3_hired == True:
                            textbutton "Every Administrative Personnel" action Show("courses", who="ad",number="4",selezione="ad") text_style "codmedcond_button_text"
            vbar value YScrollValue("my_scrollbar")
        transclude

screen courses(who,number,selezione):
    use reftrai
    use reftrai_selection(selezione)
    frame:
        side ("c r"):
            area (770, 69, 502, 497)
            viewport id "my_scrollbar":
                draggable True mousewheel True

                vbox:
                    xpos 0.52
                    ypos 0.35
                    xmaximum 300

                imagebutton auto "ui/reftrai_knowledge_%s.jpg" xpos 1 ypos 1 action ui.ChoiceJump("city_pool", "city_pool", location=None, block_all=None) focus_mask True hovered Show("gui_pool") unhovered [Hide("gui_pool")]
Can someone please help me?
Last edited by Bruni Multimedia on Fri May 17, 2019 4:35 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: SCREEN selections

#2 Post by PyTom »

I believe the problem is that Show doesn't consider screen arguments when choosing what to highlight. This isn't a bug, you'll have to program around it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: SCREEN selections

#3 Post by xavimat »

I suggest you to merge all in only one screen and use the variables to decide what part of the screen is showing as local variables. So, the button use the action SetScreenVariable() and renpy will find easily the selected/unselected buttons.

Code: Select all

screen myscreen1():  # <- Don't forget the parenthesis, even empty
    default var1 = None
    default var2 = None
    vbox xalign 0.0:
        textbutton "Uno" action SetScreenVariable("var1", 1)
        textbutton "Due" action SetScreenVariable("var1", 2)
    vbox xalign 0.5:
        if var1 == 1:
            textbutton "Uno-Uno" action SetScreenVariable("var2", 11)
            textbutton "Uno-Due" action SetScreenVariable("var2", 12)
        elif var1 == 2:    
            textbutton "Due-Uno" action SetScreenVariable("var2", 21)
            textbutton "Due-Due" action SetScreenVariable("var2", 22)
        else:
            null height 10
    vbox xalign 1.0:
        if var2 == 11:
            text "Uno-Uno"
        elif var2 == 12:
            text "Uno-Due"
        elif var2 == 21:
            text "Due-Uno"
        elif var2 == 22:
            text "Due-Due"
        else:
            null height 10
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Bruni Multimedia
Regular
Posts: 114
Joined: Mon May 15, 2017 12:23 pm
Projects: Yomi Alliance
Organization: Bruni Multimedia
itch: brunimultimedia
Contact:

Re: SCREEN selections

#4 Post by Bruni Multimedia »

Thank you very much! It worked like a charm!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]