Defining imagebuttons to stay on current screen [Solved]

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
aoarashit
Regular
Posts: 66
Joined: Sun Oct 11, 2009 12:22 pm
Contact:

Defining imagebuttons to stay on current screen [Solved]

#1 Post by aoarashit »

Here's my code for my custom menu, the 'gore mode'.

Code: Select all

    ui.vbox(spacing=0, xalign=.5,yalign=.45, xmaximum=392, ymaximum=177)
    
    ui.imagebutton("imagebu/bthomas1.png", "imagebu/bthomas2.png", clicked=ui.returns(1)) 
    ui.imagebutton("imagebu/dithomas1.png", "imagebu/dithomas2.png", clicked= ui.returns(2))

    ui.close()
    result= ui.interact()
    if result==1:        
        persistent.gore= True

    if result==2:
        persistent.gore= False

return
It does work all right, but got a few problems.
Once I click on a option, I want the buttons to stay on its activated state(Like the preference screen), so that players can see what they chose in case they forgot. I don't want return to the game screen once I click on an option. I want to stay on the current screen, with the buttons activated.

I added selected_activate_image and insensitive_image and other image related in the imagebutton properties it does not work.
Also tried jump with a new label; pretty much the same. Would be great if I get this out of my mind.. I still have tons of CG to do.(still have save/load screen problem, hope I get an answer while working on other things :D)
Last edited by aoarashit on Sat Oct 24, 2009 2:17 am, edited 1 time in total.

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Defining imagebuttons to stay on current screen

#2 Post by JQuartz »

aoarashit wrote:Once I click on a option, I want the buttons to stay on its activated state(Like the preference screen), so that players can see what they chose in case they forgot. I don't want return to the game screen once I click on an option. I want to stay on the current screen, with the buttons activated.
You can use if and jump back to the label after the ui.interact like so:

Code: Select all

label some_screen:
    python:
        ui.vbox(spacing=0, xalign=.5,yalign=.45, xmaximum=392, ymaximum=177)
        if persistent.gore:
            ui.textbutton("True Image", ui.returns(False))#this is a textbutton but you can use this concept for imagebutton as well.
        elif not persistent.gore:
            ui.textbutton("False Image", ui.returns(True))
        ui.textbutton("Return to game", ui.jumps("return_to_game"))

        ui.close()
        persistent.gore= ui.interact()
    jump some_screen
    
label return_to_game:
    return
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

aoarashit
Regular
Posts: 66
Joined: Sun Oct 11, 2009 12:22 pm
Contact:

Re: Defining imagebuttons to stay on current screen

#3 Post by aoarashit »

Thank you so much, JQuartz!

I get this weirdest error when I put jump some_screen into my code.
When I select the 'gore mode' option from the menu screen and into the game, my in-game images(xcept the background) completely disappears into nowhere. And when I right-click the menu screen(the screen when you first start the game) shows instead of the load screen. When I don't go into the gore mode and start the game, the game works fine. Is it because I use ui.images for displaying my in-game CGs? Why do I get this error?

And sorry for being such a nuisance, I tried tinkering with your code to make this sort of screen..
Image
but was unsuccessful on it. What I tried to do was write the if/elif code two times and switch the ui.returns functions. Am I on the right track? Doesn't feel like it;

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Defining imagebuttons to stay on current screen

#4 Post by JinzouTamashii »

aoarashit wrote: Once I click on a option, I want the buttons to stay on its activated state(Like the preference screen), so that players can see what they chose in case they forgot. I don't want return to the game screen once I click on an option. I want to stay on the current screen, with the buttons activated.
Strum should see this...
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: Defining imagebuttons to stay on current screen

#5 Post by JQuartz »

aoarashit wrote:When I select the 'gore mode' option from the menu screen and into the game, my in-game images(xcept the background) completely disappears into nowhere. Is it because I use ui.images for displaying my in-game CGs?
Yes. But since you need to ui.callsinnewcontext this screen, the images(including the bg) isn't supposed to stay.
aoarashit wrote:And when I right-click the menu screen(the screen when you first start the game) shows instead of the load screen.
I think it's cause you jump to the some_screen instead of renpy.call_in_new_context. If you jump then you should jump back instead of using return.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

aoarashit
Regular
Posts: 66
Joined: Sun Oct 11, 2009 12:22 pm
Contact:

Re: Defining imagebuttons to stay on current screen

#6 Post by aoarashit »

Thank you so much for all y'all help, I even got my buttons to work right! Now I can walk out a happy woman.......for now. Dang save/load!(grumble)

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Defining imagebuttons to stay on current screen [Solved]

#7 Post by JinzouTamashii »

Your avatar makes me think of you as a male... :lol:
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

aoarashit
Regular
Posts: 66
Joined: Sun Oct 11, 2009 12:22 pm
Contact:

Re: Defining imagebuttons to stay on current screen [Solved]

#8 Post by aoarashit »

JinzouTamashii wrote:Your avatar makes me think of you as a male... :lol:
I thought you were a guy til I checked out your pixiv, so we're even :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Syrale