Page 1 of 2

Over-Ambitious GUI Question (Solved)

Posted: Sun Jan 24, 2016 3:42 am
by camisteja
Hi again, it's me. I am back with another newbie question about imagemaps, but this time I wonder if this is even something that can be done.

Is it possible for the mm_ground image to be replaced with another mm_ground image when any of the buttons get hovered? Could a If Statement do the trick and how would I go about writing that?

For example, say the normal Title Screen is pink but when I hover the mouse over one of the buttons, not only do the buttons change color but the title screen has ugly green flowers all over it now. However, when the mouse leaves the button the Title Screen goes back to pink again. Does this example make sense? Hopefully I am not confusing everyone even more.

Anyway, as always, I appreciate any help you guys are inclined to give me.

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 4:22 am
by namastaii
Yes that makes sense. Hmm interesting. I'm going to look at a couple of places and come back with an idea.

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 4:26 am
by namastaii
I want to say... that on the page where the code is for the buttons on the menu, somehow when they're hovered, to add to that hover code to also change mm_ground, else keep mm_ground to the original file. I'm actually going to test it out on my engine and if I get it to work, I'll paste the code that worked

---edit:

So I need to go to bed. I'll look more into it tomorrow if you haven't already gotten help. I'm not a pro at coding on renpy but I have done quite a bit. I can mess with it more and research more. If anything you might have to make this menu somewhere else than the main menu page. I'm not sure. Good night
-Thought I did figure out a way to change the background once you hover over the buttons. Just haven't finished the part where you don't have anything hovered to have it go back to normal.

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 5:23 am
by Zetsubou
Sounds like you want a mix of hovered, unhovered, and SetScreenVariable.
Something like:

Code: Select all

screen main_menu():
        default i = 0

        if i == 0:
            add "normalBg.png"
        elif i == 1:
            add "uglyGreenFlowers.png"

        textbutton 'Start Game':
            action Start()
            hovered SetScreenVariable("i", 1)
            unhovered SetScreenVariable("i", 0)

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 12:37 pm
by namastaii
I told you someone would be way better at this. Lol Thank you Zetsubou

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 12:49 pm
by camisteja
Thank you both so much!! I really appreciate the help. ;u;

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 12:50 pm
by namastaii
This is what worked unless there's a way to make it so you don't have the hover/unhovered on every button in which I couldn't get that to work.

Code: Select all

screen main_menu:
    default i = 0

    tag menu
    if i == 0:
        add "ui/background.png"
    elif i == 1:
        add "ui/background2.png"
    add "ui/menus/mainmenu/stripe.png"
    add "ui/logo.png"
    
    imagemap:
        
        ground "ui/menus/mainmenu/mm_ground.png"
        idle "ui/menus/mainmenu/mm_ground.png"
        hover "ui/menus/mainmenu/mm_hover.png" 
        
        alpha False
        cache False
        
        
        hotspot (100,600,180,64) action Start() at buttonfade hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (338,600,146,64) action ShowMenu('load') at buttonfade hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (540, 600, 161, 64) action ShowMenu("preferences") at buttonfade hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (764,600,154,64) action Quit(confirm=False) at buttonfade hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
edit: ignore my extra stuff. It goes to the theme I was messing with to test this code.

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 3:44 pm
by camisteja
[quote="namastaii"][/quote]

Thanks so much! I managed to get your code to work with my game, although it still doesn't seem to do exactly what I want yet. I am sure with some tweaking it will.

Thanks again to you both of you for your assistance.

EDIT:

Well, I fought with it all day but it still refuses to swap the ground images. Instead, it just does the normal hover. Am I doing something wrong?

Code: Select all

##############################################################################
# Main Menu
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

screen main_menu:
    default i = 0

    tag menu
    if i == 0:
        add "blah_ground.png"
    elif i == 1:
        add "blah_bghover.png"
    
    imagemap:
        
        ground "blah_ground.png"
        idle "blah_idle.png"
        hover "blah_hover.png" 
        
        hotspot (0, 40, 378, 176) action Start() hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 136, 378, 176) action ShowMenu('load') hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 235, 378, 176) action ShowMenu("preferences") hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 325, 378, 176) action Quit(confirm=False) hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)

##############################################################################

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 11:38 pm
by philat
Probably it's the imagemap is shown on top of the background, so you can't see any change.

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 11:41 pm
by camisteja
philat wrote:Probably it's the imagemap is shown on top of the background, so you can't see any change.
Even if I use two different backgrounds? I tried putting the idle+hover buttons on their own transparent image and made the two backgrounds totally separate. Shouldn't the If Statement still work in that case?

Re: Over-Ambitious GUI Question

Posted: Sun Jan 24, 2016 11:55 pm
by namastaii
Wait so what exactly is the problem?

Re: Over-Ambitious GUI Question

Posted: Mon Jan 25, 2016 12:01 am
by namastaii
From my understanding the ground is supposed to be the menu text, right? Are you trying to swap the menu text or the backgrounds? To change the backgrounds, that code should work. I just checked again

Re: Over-Ambitious GUI Question

Posted: Mon Jan 25, 2016 12:08 am
by philat
camisteja wrote:
philat wrote:Probably it's the imagemap is shown on top of the background, so you can't see any change.
Even if I use two different backgrounds? I tried putting the idle+hover buttons on their own transparent image and made the two backgrounds totally separate. Shouldn't the If Statement still work in that case?
I don't know, since I don't know what your images look like, but unless you edited the code before posting, you're using blah_ground.png in both the background and imagemap, so I assumed both were fullscreen backgrounds.

Re: Over-Ambitious GUI Question

Posted: Mon Jan 25, 2016 12:25 am
by namastaii
under imagemap put alpha False

Code: Select all

##############################################################################
# Main Menu
#
# Screen that's used to display the main menu, when Ren'Py first starts
# http://www.renpy.org/doc/html/screen_special.html#main-menu

screen main_menu:
    default i = 0

    tag menu
    if i == 0:
        add "blah_ground.png"
    elif i == 1:
        add "blah_bghover.png"
    
    imagemap:
        
        ground "blah_ground.png"
        idle "blah_idle.png"
        hover "blah_hover.png" 

        alpha False
        cache False


        
        hotspot (0, 40, 378, 176) action Start() hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 136, 378, 176) action ShowMenu('load') hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 235, 378, 176) action ShowMenu("preferences") hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)
        hotspot (0, 325, 378, 176) action Quit(confirm=False) hovered SetScreenVariable("i", 1) unhovered SetScreenVariable("i", 0)

##############################################################################
making alpha false I believe makes it so the buttons are only active when the actual text is being hovered. I can see if that this could have been a problem if your menu text image is as big as the entire screen.

Re: Over-Ambitious GUI Question (Solved)

Posted: Mon Jan 25, 2016 1:06 am
by camisteja
namastaii wrote: making alpha false I believe makes it so the buttons are only active when the actual text is being hovered. I can see if that this could have been a problem if your menu text image is as big as the entire screen.
I got rid of the alpha/cache section because it didn't work originally, so I thought that maybe it wasn't needed. I added it back in, but no dice. :/

Thank you again everyone for your inputs. I'm starting to believe it just isn't possible. Lol