Page 1 of 1

Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 2:27 pm
by iDweadith
So, I want to hide a single textbutton when I click on it, but I don't know how! If I hide screens I will hide all buttons, while I wanna hide just one button that is the one clicked



Something like: when click on the button "open" it dissappear and another texbutton named "close" appears

Re: Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 3:01 pm
by rayminator
something like this.. this is what I'm using but I got from someone else I'm just using it

Code: Select all

init 1:
    $ mod_show = False
    $ mod_button_show = True

screen cheat:


    if mod_button_show:
        if renpy.loadable("cheatmod.rpy"):
            if mod_show == False:
                imagebutton xalign 0.10 ypos 0.02:
                    idle ("enter_mod_idle")
                    hover ("enter_mod_hover")
                    action [ Show("more_cheats"), SetVariable("mod_show", True)]
            else:
                imagebutton xalign 0.10 ypos 0.02:
                    idle ("exit_mod_idle")
                    hover ("exit_mod_hover")
                    if mod_show == True:
                        action [ Hide("more_cheats"), SetVariable("mod_show", False)]

style show_mod_button:
    size 42
    #bold True
    color "#1DDB16" # E60000
    hover_color "#d94c3a"
    outlines [(3, "#222222", 0, 0)]

style hide_mod_button:
    size 42
    #bold True
    color "#E60000" # E60000
    hover_color "#d94c3a"
    outlines [(3, "#222222", 0, 0)]

style ds_mod_style_close_button:
    size 40
    #bold True
    color "#00589E" # E60000
    hover_color "#E60000"
    outlines [(3, "#000", 0,0)]

style hover_color_buttons:
    size 35
    hover_color "#d94c3a"

style ds_mod_style:
    bold True
    color "#00589E" # E60000
    hover_color "#c184ff"
    outlines [(3, "#000", 0,0)]

style ds_mod_style_red:
    bold True
    color "#E60000" # E60000
    hover_color "#c184ff"
    outlines [(3, "#000", 0,0)]

image enter_mod_idle = "images/cheat/hacker_cyber_crime-512.png"

image enter_mod_hover = "images/cheat/hacker_cyber_crime-5123.png"

image exit_mod_idle = "images/cheat/hacker_cyber_crime-512.png"

image exit_mod_hover = "images/cheat/hacker_cyber_crime-5123.png"

Re: Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 5:52 pm
by iDweadith
It worksss! Thank you rayminator

I never knew I could use conditional statements into a screen

Re: Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 7:06 pm
by iDweadith
Another question

So I did something like

Code: Select all

init 1:
    $ mod_show = False
    $ mod_button_show = True

screen admin_screen:
        if mod_button_show:
            if mod_show == False:
                textbutton "Hello" action SetVariable("mod_show", "True")
            elif mod_show == True:
                textbutton "Hello2" action SetVariable("mod_show", "False")
But this doesn't work well

Re: Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 8:35 pm
by strayerror
True and False in your SetVariable calls should not be quoted. :)

Additionally you could even simplify this to:

Code: Select all

screen admin_screen:
    default open = False

    if open:
        textbutton "Hello2" action SetScreenVariable('open', False)
    else:
        textbutton "Hello" action SetScreenVariable('open', True)
Which has the advantage of keeping the variable open contained within the screen itself. If this is not wanted (i.e. you want open to be global) then changing SetScreenVariable to SetVariable should have you covered. :D

Re: Is that possible to hide/unhide textbutton?

Posted: Wed Jun 17, 2020 8:57 pm
by rayminator
this what I have created

Code: Select all

if mod_button_show:
        if mod_show == False:
            textbutton "Hello" action SetVariable("mod_show", True) xalign 0.10 ypos 0.02
        elif mod_show == True:
            textbutton "Hello2" action SetVariable("mod_show", False) xalign 0.10 ypos 0.02

Re: Is that possible to hide/unhide textbutton?

Posted: Thu Jun 18, 2020 12:47 am
by Imperf3kt
I'd simplify it further to

Code: Select all

screen testing():
    default var1 = True

    vbox:
        if var1:
            textbutton _("one") action ToggleScreenVariable("var1", False)
        else:
            textbutton _("two") action ToggleScreenVariable("var1", True)

Re: Is that possible to hide/unhide textbutton?

Posted: Thu Jun 18, 2020 4:30 am
by iDweadith
Thank you again guys it works perfectly!!!