Changing game menu UI, it KINDA works...

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
xiruo
Newbie
Posts: 10
Joined: Wed Nov 30, 2022 7:14 am
itch: no-xiruo
Contact:

Changing game menu UI, it KINDA works...

#1 Post by xiruo »

So I want to be able to change the game menu UI mid-game multiple times. (Basically, I'm changing character POV and I want the game menu to reflect that.)

I set up a default variable that I change to the character's name when I want to change the game menu. I have the variable in options.rpy:

Code: Select all

#For POV
default POV = "viv"
And then I have the images in their proper folders so I can do this:

Code: Select all

#NAVIGATION:
        add "gui/game_menu_assets/[POV]/main_note_bg.png" at note_menu_movein
        imagebutton:
            idle "gui/game_menu_assets/[POV]/about_idle.png"
            hover "gui/game_menu_assets/[POV]/about_hover.png"
            selected_idle "gui/game_menu_assets/[POV]/about_hover.png"
            selected_hover "gui/game_menu_assets/[POV]/about_hover.png"
            selected title == "About"
            focus_mask True
            action ShowMenu("about")
            at note_menu_movein
        imagebutton:
            idle "gui/game_menu_assets/[POV]/help_idle.png"
            hover "gui/game_menu_assets/[POV]/help_hover.png"
            selected_idle "gui/game_menu_assets/[POV]/help_hover.png"
            selected_hover "gui/game_menu_assets/[POV]/help_hover.png"
            selected title == "Help"
            focus_mask True
            action ShowMenu("help")
            at note_menu_movein
## ETC... you get the idea
I'm testing this in game and it works... sort of.
When I hit the point where I change the variable and then open the menu, all of the buttons will have changed to the other UI button.
BUT the images (the ones that I used "add" with) stay as the previous version. If I open the game menu AGAIN, it will change to the new UI.

Before I change the variable:
Image

After the variable change, upon opening game menu initially:
Image

Opening it a second time:
Image

My question is, what should I do so that everything changes upon opening the game menu the first time? It seems like the buttons will immediately change, but the images require you to open the menu TWICE before it changes?

I'm not sure how to fix this. My brute force idea is to make all the image into non-clickable buttons to force it to happen. But I don't think that's a smart idea, LMAO.

Thank you!!
ᕕ( ᐛ )ᕗ ᕕ( ᐕ )ᕗ

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1057
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Changing game menu UI, it KINDA works...

#2 Post by m_from_space »

xiruo wrote: Mon Jan 08, 2024 1:51 am So I want to be able to change the game menu UI mid-game multiple times. (Basically, I'm changing character POV and I want the game menu to reflect that.)
My first thought on this is, that you are using a "default" variable for the game menu, which is a bit odd, because the game menu (or main menu) can be accessed while not in a game and while in a game. And "default" variables are used for in-game content, not menu stuff - in general. The reason is that they will be "reset" to their default values when a new game starts and set to their saved values when the game loads.

So what does the game menu have to look like when the player opens up your game? (I don't mean loading a game.)

Or do you only care about its look when inside a running game?
My question is, what should I do so that everything changes upon opening the game menu the first time?
Yeah, what do you mean by that? From within a running game (hitting ESC or right mouse button) or when starting up your game from the OS - entering the main menu so to speak? If you want to remember the last change, you will have to use a persistent variable.
I'm not sure how to fix this. My brute force idea is to make all the image into non-clickable buttons to force it to happen. But I don't think that's a smart idea, LMAO.
When you change the variable, you may want to call:

Code: Select all

$ POV = "whatever"
# force all screens to redraw
$ renpy.restart_interaction()
Tell me if that helps.

Post Reply

Who is online

Users browsing this forum: No registered users