UI customization issues

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.
Message
Author
User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

UI customization issues

#1 Post by Brendan Just » Wed Jan 13, 2016 5:45 pm

Hello, I'm just getting started so please forgive me my amateurishness.

I'm trying to customize UI, in particular buttons and menus, and was following this tutorial. The problems I have is that:

A) While trying to manage styling, I notice that the examples look like this
Image
while on my end the area looks like this
Image
I understand the changes, but it eludes me how and where to apply the example, nothing seem to work. As in:
Image
B) Where do you have to place your custom UI images? In the same folder as characters etc.?

Thank you.

User avatar
Keinart
Regular
Posts: 133
Joined: Sun May 13, 2012 8:28 pm
Completed: One Thousand Lies
Projects: Lotus Reverie
Organization: Keinart Lobre
Tumblr: keinart
itch: keinart
Location: Spain
Contact:

Re: UI customization issues

#2 Post by Keinart » Wed Jan 13, 2016 8:59 pm

A) It's the same, it's just that using colon lets you put all the properties in different lines, while the = makes you put it all in the same line. But it's the same. Now, you don't having the background button one is normal, it's not included, you have to add it to your code. Feel free to just copy paste it right below the others, and don't worry about having some with colons and some others without it, it's the same.

If you are not understanding what styling is in general or what exactly they do read this. Basically the buttons for the preferences menu are called "pref_buttons", so if you want to edit it you have to change it's properties. The background one is applying a background to the button is it uses an image instead of a color fill to create your button, but in my opinion if you are gonna use images for your buttons is easier to go for imagebuttons or imagemaps, that way you can forget about the style properties for every little thing. Recommended tutorials for those you can find them here and here. The first one comes with examples and everything so it's a must have that it's kinda hidden so no many new users know about it.

B) Anywhere inside your folder game, really. People usually make a new folder in the root called UI then you put it all there. Then when using them just make sure it's written like "UI/yourimage.png" and not just yourimage.

C) A small tip, when trying to use code in the forum you don't need to take screenshots of everything, feel free to copy paste inside [ code] [/ code] without the spaces, that way people can copy paste and stuff to help you out better.

Code: Select all

It will look like this when using code.

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#3 Post by Brendan Just » Thu Jan 14, 2016 7:54 am

Wow, thanks a lot! That game tutorial should be stickied or something, makes things so much easier to grasp)

Got everything to work.

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#4 Post by Brendan Just » Fri Jan 15, 2016 7:03 am

Got everything to work.
Okay, not exactly everything :o

I got everything to work except for choice menus.

If this is the default code how exactly do you apply an imagebutton here?

Code: Select all

screen choice(items):

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.9

        vbox:
            style "menu"
            spacing 2

            for caption, action, chosen in items:

                if action:

                    button:
                        action action
                        style "menu_choice_button"

                        text caption style "menu_choice"

                else:
                    text caption style "menu_caption"

init -2:
    $ config.narrator_menu = True

    style menu_window is default

    style menu_choice is button_text:
        clear

    style menu_choice_button is button:
        xminimum int(config.screen_width * 0.75)
        xmaximum int(config.screen_width * 0.75)

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: UI customization issues

#5 Post by philat » Fri Jan 15, 2016 9:03 am

Without some working knowledge of Renpy's innards, you shouldn't. If you just want to customize the way the buttons look, change the style of "menu_choice_button" (for instance, give it a background image).

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#6 Post by Brendan Just » Fri Jan 15, 2016 9:43 am

philat wrote:If you just want to customize the way the buttons look, change the style of "menu_choice_button" (for instance, give it a background image).
Yeah, that's what I want, I just can't figure out how exactly to change it in this instance.

Like if this, let's say, a line for the start button in the main menu

Code: Select all

imagebutton auto "gui/main_start_%s.png" action Start() xpos 490 ypos 190 focus_mask True
how should one look here?

User avatar
Keinart
Regular
Posts: 133
Joined: Sun May 13, 2012 8:28 pm
Completed: One Thousand Lies
Projects: Lotus Reverie
Organization: Keinart Lobre
Tumblr: keinart
itch: keinart
Location: Spain
Contact:

Re: UI customization issues

#7 Post by Keinart » Fri Jan 15, 2016 2:12 pm

Well, the thing is that the choice screen is kinda premade in renpy so can add your choices and stuff ingame during the script, is a bit harder than all the other menus. Still I think you can just follow what the last user here says and it should work. Haven'ts tried it myself though.

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#8 Post by Brendan Just » Sat Jan 16, 2016 8:00 am

Keinart wrote:Well, the thing is that the choice screen is kinda premade in renpy so can add your choices and stuff ingame during the script, is a bit harder than all the other menus. Still I think you can just follow what the last user here says and it should work. Haven'ts tried it myself though.
Thanks. The code in the last post there works great, but the choices don't appear over the buttons, instead when you hover a cursor over the buttons they appear in the dialog window.
Last edited by Brendan Just on Sat Jan 16, 2016 12:07 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: UI customization issues

#9 Post by philat » Sat Jan 16, 2016 11:12 am

Find style menu_choice_button and modify it.

Code: Select all

# if you want to use an image with a Frame (can change size according to length of choice)
    style menu_choice_button is button:
        xminimum int(config.screen_width * 0.75)
        xmaximum int(config.screen_width * 0.75)
        background Frame("image path here", 10, 10) # adjust numbers as necessary

# if you want to use a fixed image (simpler, just have to make sure the choices don't overflow)
    style menu_choice_button is button:
        xsize 500 # the number is a placeholder, make it the size of your image
        background "image path here"

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#10 Post by Brendan Just » Sat Jan 16, 2016 12:00 pm

philat wrote:Find style menu_choice_button and modify it.
This works but I really like the imagebutton method from above. Just need to find a way to display choices over buttons.

User avatar
Keinart
Regular
Posts: 133
Joined: Sun May 13, 2012 8:28 pm
Completed: One Thousand Lies
Projects: Lotus Reverie
Organization: Keinart Lobre
Tumblr: keinart
itch: keinart
Location: Spain
Contact:

Re: UI customization issues

#11 Post by Keinart » Sat Jan 16, 2016 12:40 pm

Brendan Just wrote:
Keinart wrote:Well, the thing is that the choice screen is kinda premade in renpy so can add your choices and stuff ingame during the script, is a bit harder than all the other menus. Still I think you can just follow what the last user here says and it should work. Haven'ts tried it myself though.
Thanks. The code in the last post there works great, but the choices don't appear over the buttons, instead when you hover a cursor over the buttons they appear in the dialog window.
The issue with imagebuttons is that they are full images, no text, so that's why the text appears below the buttons. So you have to create the images with the text already in them, then in the code don't add any text. Same if you try to do it with imagemaps.

In the other hand, if you want to be able to have the text in the code you'll have to follow the other way to create buttons. So at the end it depends of what you need, if you're going to have a lot of choices it's better to create a standard button so then you only have to change the text for each, but if you only will have a couple choices or each choice will be completely different imagebutton or imagemap is easier.

I guess you could also make it in a way you combine the two of them, leaving the imagebuttons below and creating a style for the choice buttons without background or anything, just text, then putting it over the imagebutton, but I don't think that would be useful.

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#12 Post by Brendan Just » Sat Jan 16, 2016 6:08 pm

Keinart wrote:
Brendan Just wrote:
Keinart wrote:Well, the thing is that the choice screen is kinda premade in renpy so can add your choices and stuff ingame during the script, is a bit harder than all the other menus. Still I think you can just follow what the last user here says and it should work. Haven'ts tried it myself though.
Thanks. The code in the last post there works great, but the choices don't appear over the buttons, instead when you hover a cursor over the buttons they appear in the dialog window.
The issue with imagebuttons is that they are full images, no text, so that's why the text appears below the buttons. So you have to create the images with the text already in them, then in the code don't add any text. Same if you try to do it with imagemaps.

In the other hand, if you want to be able to have the text in the code you'll have to follow the other way to create buttons. So at the end it depends of what you need, if you're going to have a lot of choices it's better to create a standard button so then you only have to change the text for each, but if you only will have a couple choices or each choice will be completely different imagebutton or imagemap is easier.

I guess you could also make it in a way you combine the two of them, leaving the imagebuttons below and creating a style for the choice buttons without background or anything, just text, then putting it over the imagebutton, but I don't think that would be useful.
I see, that makes sense. I have a lot of choices so I'll go with choice button modification for text choices and leave imagebuttons for visuals choices.

With that I have, hopefully, the last issue - I got everything working with menu choice button, but the text in the choice buttons, while working just fine, doesn't highlight as you hover the mouse over it.

User avatar
Keinart
Regular
Posts: 133
Joined: Sun May 13, 2012 8:28 pm
Completed: One Thousand Lies
Projects: Lotus Reverie
Organization: Keinart Lobre
Tumblr: keinart
itch: keinart
Location: Spain
Contact:

Re: UI customization issues

#13 Post by Keinart » Sat Jan 16, 2016 7:29 pm

Add this in your init -2 in the choice section of your screen.rpy file

Code: Select all

style.menu_choice_text.hover_color = "#FFFFFF"
You can change the "#FFFFFF" for any color you want.

User avatar
Brendan Just
Newbie
Posts: 12
Joined: Wed Jan 13, 2016 4:38 pm
Contact:

Re: UI customization issues

#14 Post by Brendan Just » Sat Jan 16, 2016 9:10 pm

Hmm, I'm getting an error:

Code: Select all

File "game/screens.rpy", line 104: expected 'word' not found.
    style.menu_choice_text.hover_color = "#FFFFFF"
or

Code: Select all

File "game/screens.rpy", line 104: expected 'simple_expression' not found.
    style menu_choice_text hover_color = "#FFFFFF"
I went over style properties tutorials and tried several things, but this keeps happening. I kinda circumvented the problem by making the buttons themselves highlight, but I just wanna find out why this doesn't work for me, seems like such a simple command.

User avatar
Keinart
Regular
Posts: 133
Joined: Sun May 13, 2012 8:28 pm
Completed: One Thousand Lies
Projects: Lotus Reverie
Organization: Keinart Lobre
Tumblr: keinart
itch: keinart
Location: Spain
Contact:

Re: UI customization issues

#15 Post by Keinart » Sat Jan 16, 2016 10:49 pm

Whoops sorry my fault, the style for choices doesn't need the text part. I got it wrong because usually for every menu you have differenciate text from the rest, but not for this one. So just leave it like this.
style.menu_choice.hover_color = "#WhateverColor"
Still, even if you had it as I mentioned in my previous post no error message should come out, so if something keeps going wrong make sure it's correctly written within the code, with the same margin as the rest style properties and all that jazz.

Post Reply

Who is online

Users browsing this forum: No registered users