[SOLVED] Textbutton with State-Dependent Text
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.
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.
- KnotUntied
- Newbie
- Posts: 23
- Joined: Mon Jan 04, 2016 5:36 am
- Projects: Acheron
- IRC Nick: Knot
- Contact:
[SOLVED] Textbutton with State-Dependent Text
I plan on creating textbuttons with text that varies between states, something like:
Insensitive - [cantclickdis]
Selected - [youclickeddis]
Standard - [nothinghappened]
Is this possible? Did I miss some documentation concerning such? Has this question been asked already?
I will try to clarify if required.
Insensitive - [cantclickdis]
Selected - [youclickeddis]
Standard - [nothinghappened]
Is this possible? Did I miss some documentation concerning such? Has this question been asked already?
I will try to clarify if required.
Last edited by KnotUntied on Mon May 23, 2016 7:54 pm, edited 1 time in total.
I don't always make something, but when I do, I never fini
Re: Textbutton with State-Dependent Text
Yes...KnotUntied wrote:Did I miss some documentation concerning such?
Chances are that it was.KnotUntied wrote:Has this question been asked already?
You can create styles or pass style properties to you buttons directly.
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Textbutton with State-Dependent Text
I think you'll want to use imagebuttons for this. You can assign a different image based on button state as insensitive, sensitive, or selected by using styling. If you want it to look like a textbutton you can use text displayables.
Edit to add: ok you can use a button, you can change the child displayable based on state.
Edit to add: ok you can use a button, you can change the child displayable based on state.
Re: Textbutton with State-Dependent Text
...?saguaro wrote:I think you'll want to use imagebuttons for this. You can assign a different image based on button state as insensitive, sensitive, or selected by using styling. If you want it to look like a textbutton you can use text displayables.
- KnotUntied
- Newbie
- Posts: 23
- Joined: Mon Jan 04, 2016 5:36 am
- Projects: Acheron
- IRC Nick: Knot
- Contact:
Re: Textbutton with State-Dependent Text
Is there a way to allow strings instead of file locations in imagebuttons, then?
I don't always make something, but when I do, I never fini
Re: Textbutton with State-Dependent Text
I have no idea why imagebuttons were suggested to be used instead of textbuttons for buttons that are used to display text Ask the other guy...KnotUntied wrote:Is there a way to allow strings instead of file locations in imagebuttons, then?
Re: Textbutton with State-Dependent Text
Basically some form of this, you don't need style, I misunderstood your question at first:
Code: Select all
style meow_button_text:
idle_color "FFF"
hover_color "F00"
selected_color "000"
selected_hover_color "F0F"
screen test():
default meow = ":)"
textbutton "[meow]":
align .5, .5
style "meow_button"
action SetScreenVariable("meow", ":("), SensitiveIf(not meow == ":(")
hovered SetScreenVariable("meow", "Cliiiiick me noooooooow!")
unhovered SetScreenVariable("meow", ":)")
label start:
call screen test
- korova
- Veteran
- Posts: 217
- Joined: Sat Jun 27, 2009 5:15 pm
- Completed: Ivy, Chocolate, Time, Clair Obscur
- Projects: Writing exercises, The House [Nano18]
- Tumblr: korova08
- itch: korova
- Location: Normandie, France
- Contact:
Re: Textbutton with State-Dependent Text
This is what I use in my scripts to achieve that effect
Code: Select all
imagebutton:
style "accueil_button"
idle Text("Text idle",style = "accueil_icone")
hover Text("Text hover"), style = "accueil_texte")
selected Text("Text selected"), style = "accueil_texte")
action Start()
Re: Textbutton with State-Dependent Text
Good one, in the past you could only assign Displayable to buttons (imagebuttons threw errors)... "image"button is not really a correct name anymore Usually with image in Ren'Py, reference is made either to tagging system or to image like displayable.korova wrote:This is what I use in my scripts to achieve that effect
Code: Select all
imagebutton: style "accueil_button" idle Text("Text idle",style = "accueil_icone") hover Text("Text hover"), style = "accueil_texte") selected Text("Text selected"), style = "accueil_texte") action Start()
- KnotUntied
- Newbie
- Posts: 23
- Joined: Mon Jan 04, 2016 5:36 am
- Projects: Acheron
- IRC Nick: Knot
- Contact:
Re: Textbutton with State-Dependent Text
I implemented korova's method, which did what I wanted, except for the text displaying insensitive color all the time.
UPDATE: I also tried implementing saguaro's alternate idea, which involved buttons and children, and it did provide a lighter footprint, but went insane with "child Text("Test", etc)" not registering and having the unselected button cover the area with void.
UPDATE: I also tried implementing saguaro's alternate idea, which involved buttons and children, and it did provide a lighter footprint, but went insane with "child Text("Test", etc)" not registering and having the unselected button cover the area with void.
Code: Select all
button:
child Text("Testing...", style = "pref_button_text") # Does nothing, eats display space
selected_child Text("SUCCESS!", style = "pref_button_text") # Works except for color, same issue with imagebutton attempt
action Preference("skip", "seen")
I don't always make something, but when I do, I never fini
- korova
- Veteran
- Posts: 217
- Joined: Sat Jun 27, 2009 5:15 pm
- Completed: Ivy, Chocolate, Time, Clair Obscur
- Projects: Writing exercises, The House [Nano18]
- Tumblr: korova08
- itch: korova
- Location: Normandie, France
- Contact:
Re: Textbutton with State-Dependent Text
KnotUntied wrote:I implemented korova's method, which did what I wanted, except for the text displaying insensitive color all the time.
Unfortunately, you have to assign a specific text-style to each text.
I know this is heavy, but I found no other easier alternative.
So you have to define a "text_idle" style, to assign to your idle version of the button, s "selected_text" style for the selected version and such.
I'm not very happy with this either, but as for now, this is the best I can do...
Code: Select all
imagebutton:
style "accueil_button"
idle Text("Text idle",style = "idle_text")
hover Text("Text hover"), style = "hover_text")
selected Text("Text selected"), style = "selected_text")
action Start()
Code: Select all
style idle_text:
color my_idle_color
style hover_text:
color my_hover_color
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Textbutton with State-Dependent Text
Re: Button: I tried but could do no better unfortunately. It has to do with how the Text displayable handles styles?
Code: Select all
screen button_test():
default select = False
button:
xsize 120 ysize 20
idle_child Text("Idle", style="test_text")
hover_child Text("Hover", style="test_text")
selected_child Text("Selected", style="selected_text")
action ToggleScreenVariable("select")
style test_text:
color "#000"
style selected_text:
color "#088"
- KnotUntied
- Newbie
- Posts: 23
- Joined: Mon Jan 04, 2016 5:36 am
- Projects: Acheron
- IRC Nick: Knot
- Contact:
Re: Textbutton with State-Dependent Text
After some graphical adjustments, I finally obtained my desired results.
Despite the barbarous length of code required, I guess I'll have to sit with saguaro's solution.
Thanks for your help, gents!
Despite the barbarous length of code required, I guess I'll have to sit with saguaro's solution.
Thanks for your help, gents!
I don't always make something, but when I do, I never fini
Who is online
Users browsing this forum: Semrush [Bot]