Looking for help replacing the textbx gui with image buttons

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
TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Looking for help replacing the textbx gui with image buttons

#1 Post by TheOtherNewGuy »

Looking to replace the textbox gui with buttons with images. I'm currently using renpy 6.99.11, and have been trying to learn the language through the documentation. Trying to understand how all this works together is a bit hard for a newbie, especially since it seems all the examples ive searched for in the forums are based on older versions of renpy, and finding what the code has been changed to is like turning the lights off while trying to do a puzzle.

this is what I want to do.

I'd like to change the ui text from
Image
to my own custom image buttons displayed here as random shapes.

from what ive read so far I suspect that all this can be done in the screens rpy? problem is I don't have enough experience with coding to make sense of broad explanations.

If anyone can give me some pointers I'd appreciate it. I've checked out the image maps tutorial in the cookbook thread and the gui documentation as well. If I can get any closer to understanding how renpy code works I'll be happy.

I'm also wondering if its possible to make these buttons curved.

thanks.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Looking for help replacing the textbx gui with image but

#2 Post by Ocelot »

TheOtherNewGuy wrote:I suspect that all this can be done in the screens rpy?
Yes. In particular, you are interested in quick_menu screen. Just replace those textbutons with your imagebuttons.
TheOtherNewGuy wrote:I'm also wondering if its possible to make these buttons curved.
You mean, that you would need to click inside button shape and not in general rectangle? Then yes, check focus_mask style property.
< < insert Rick Cook quote here > >

TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Re: Looking for help replacing the textbx gui with image but

#3 Post by TheOtherNewGuy »

Thanks for the reply. Please bear with me, when it comes to coding i'm like a grandparent trying to use a smartphone.

so it would look something like this?

Code: Select all

screen quick_menu():

    # Ensure this appears on top of other screens.
    zorder 100

    # Add an in-game quick menu.
    hbox:
        style_prefix "quick"

        xalign 0.5
        yalign 1.0

        imagebutton auto "myimage_%s.png" action Rollback()
i read a bit about imagebuttons. so all images have to have _%s at the end of them? something to do with "auto" something.


Edit: sry I forgot to delete that sentence about not finding quick_menus.
Last edited by TheOtherNewGuy on Tue Nov 22, 2016 10:54 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Looking for help replacing the textbx gui with image but

#4 Post by Ocelot »

Yes, something like that. Yes, you need to have %s in your name string, if you are using 'auto' property: it will be replaced by other strings to get image name. Here is a documentation for imagebuttons.

quick_menu is nothing special. It is just a screen. Not even a special one (like 'say' screen). This is why it is not mentioned in documentation.
< < insert Rick Cook quote here > >

TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Re: Looking for help replacing the textbx gui with image but

#5 Post by TheOtherNewGuy »

Ocelot wrote:Yes, something like that. Yes, you need to have %s in your name string, if you are using 'auto' property: it will be replaced by other strings to get image name. Here is a documentation for imagebuttons.

quick_menu is nothing special. It is just a screen. Not even a special one (like 'say' screen). This is why it is not mentioned in documentation.
okay this is my test line

Code: Select all

 imagebutton auto "imagebuttons/button 2_%s.png" action Preference("auto-forward", "toggle")
It's giving me an error. "Exception: Not a displayable: None". That was the only line i changed in the screens rpy.

i made an imagebuttons folder in my game/gui folder.and there's a file called "button 2.png" in there. at first I named my file "button 2_%s" thinking I had to add the "_%s" to the actual file name (because i have no idea how to code). but i tried several names and tried several things, but guessing doesn't usually work. any idea whats going on?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Looking for help replacing the textbx gui with image but

#6 Post by Ocelot »

I lionked to dicumentation:
Imagebutton documentation wrote:Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property.

For example, if auto is "button_%s.png", and idle is omitted, then idle defaults to "button_idle.png". Similarly, if auto is "button %s", the button idle image is used.
You need to name your files button 2_idle.png, button 2_ground.png, etc.
< < insert Rick Cook quote here > >

TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Re: Looking for help replacing the textbx gui with image but

#7 Post by TheOtherNewGuy »

Okay changing it to button 2_idle.png worked.

But here's my question. How in this paragraph
Imagebutton documentation wrote:Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property.

For example, if auto is "button_%s.png", and idle is omitted, then idle defaults to "button_idle.png". Similarly, if auto is "button %s", the button idle image is used.
did you read *Hey, Ren'Py user, if you want to create an image button, you must name your file 'button_idle.png', and then use the %s explained here to make it show up in game*?

I see the "button_idle.png" in there, but as far as instructions go you'd have to just be like "i give up, ill try adding _idle to the filename because I don't know what else to do but try every possible thing imaginable" to figure that out, at least from a beginner's point of view.

Is there something else that people read beforehand to make that answer jump out at them?
Last edited by TheOtherNewGuy on Wed Nov 23, 2016 4:57 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Looking for help replacing the textbx gui with image but

#8 Post by Ocelot »

TheOtherNewGuy wrote:Okay changing it to button 2_idle.png worked.

But here's my question. How in this paragraph

did you read *Hey, Ren'Py user, if you want to create an image button, you must name your file 'button_idle.png, and then use the %s explained here to make it show up in game*?
This is simple:
Documentation wrote:Imagebutton
Creates a button consisting of images, that change state when the user hovers over them. This takes no parameters, and the following properties:
auto
Used to automatically define the images used by this button. This should be a string that contains %s in it. If it is, and one of the image properties is omitted, %s is replaced with the name of that property, and the value is used as the default for that property.
Ok, I want to see what other properties are, so I would know what I could omit/replace.
Documentation wrote:insensitive
The image used when the button is insensitive.
idle
The image used when the button is not focused.
hover
The image used when the button is focused.
selected_idle
The image used when the button is selected and idle.
selected_hover
The image used when the button is selected and hovered.
Bingo. So you now have names of properties which would be tried instead of %s to make image paths. To clear possible confusion about terminology and spare you from reading Button documentation:
focused means your mouse is pointing at it.
insensitive means that button cannot be clicked (has no action by default)
selected is not used often, but is used to show currently selected option. Used for things like checkboxes/places you currently are in/etc.
< < insert Rick Cook quote here > >

TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Re: Looking for help replacing the textbx gui with image but

#9 Post by TheOtherNewGuy »

Welp, hopefully messing with this enough will make me think like you do.

For some reason I look at all that information and the idea to *okay step number 1: at the end of your file name you type an underscore and the name of the property.* doesn't pop up. I'll definitely be using the forums to bridge my beginner gaps.

Alright then, gonna check out the focus maps now.

Post Reply

Who is online

Users browsing this forum: Dark79, Ikaros_OwO, Zapor