Page 1 of 1

[Solved] Continue game from last save

Posted: Tue Sep 11, 2018 4:02 pm
by kostek00
I wanted to make "Continue" button to load last saved game. After checking forum I found this and used it in my game which works as intendet. The problem is that button "Continue" is always in selected state and hovering on it doesn't change it's state nor it goes to idle state. Any solution for that?

Here is whole code:

Code: Select all

screen main_menu:
    tag menu
    add "images/gui/gui_ground.png"
    add "images/gui/title.png" anchor(1.0, 0.0) pos(787,18)

    imagemap:
        ground Null()
        idle "images/gui/main_menu_idle.png"
        hover "images/gui/main_menu_hover.png"
        selected_idle "images/gui/main_menu_selected.png"
        selected_hover "images/gui/main_menu_selected.png"

        alpha False

        $ lastsave=renpy.newest_slot(r"\d+")
        if lastsave is not None:
            $ name, page = lastsave.split("-")
            hotspot(622,275,150,45) action FileLoad(name, page)
        hotspot(622,325,150,45) action Start()
        hotspot(622,375,150,45) action ShowMenu("load")
        hotspot(622,425,150,45) action ShowMenu("extra")
        hotspot(622,475,150,45) action ShowMenu("options")
        hotspot(622,525,150,45) action Quit(confirm=True)

    key "K_ESCAPE" action Quit(confirm=True)

Re: Continue game from last save with imagemap

Posted: Fri Sep 14, 2018 6:07 pm
by Qlara
Do you perhaps have a screenshot?
Do the other buttons work as they should?
Is it okay to have just one hover image? I always have one for each button.

Re: Continue game from last save with imagemap

Posted: Sat Sep 15, 2018 3:22 am
by kostek00
Qlara wrote:
Fri Sep 14, 2018 6:07 pm
Do you perhaps have a screenshot?
It's nsfw, I can't put it here.
Qlara wrote:
Fri Sep 14, 2018 6:07 pm
Do the other buttons work as they should?
Yes.
Qlara wrote:
Fri Sep 14, 2018 6:07 pm
Is it okay to have just one hover image? I always have one for each button.
Yes, I did that.


So yesteryday at night I tried some other thing and now I understand what happens but I don't know why. It appears as this code always prefers "selected" state. So I moved them to imagebutton and used only idle and hover states and that worked.

Code: Select all

screen main_menu:
    tag menu
    add "images/gui/gui_ground.png"
    add "images/gui/title.png" anchor(1.0, 0.0) pos(787,18)

    $ lastsave=renpy.newest_slot(r"\d+")
    if lastsave is not None:
        $ name, page = lastsave.split("-")
        imagebutton:
            idle im.Crop("images/gui/main_menu_idle.png", (622,275,150,45))
            hover im.Crop("images/gui/main_menu_hover.png", (622,275,150,45))
            action FileLoad(name, page)
            pos(622,275)
            focus_mask None

    imagemap:
        ground Null()
        idle "images/gui/main_menu_idle.png"
        hover "images/gui/main_menu_hover.png"
        selected_idle "images/gui/main_menu_selected.png"
        selected_hover "images/gui/main_menu_selected.png"

        alpha False


        hotspot(622,325,150,45) action Start()
        hotspot(622,375,150,45) action ShowMenu("load")
        hotspot(622,425,150,45) action ShowMenu("extra")
        hotspot(622,475,150,45) action ShowMenu("options")
        hotspot(622,525,150,45) action Quit(confirm=True)

    key "K_ESCAPE" action Quit(confirm=True)
Now I see different bug with this code. It looks like it's only loading normal saves and ignores quick saves.

Re: Continue game from last save with imagemap

Posted: Sat Sep 15, 2018 8:00 am
by Andredron

Re: Continue game from last save with imagemap

Posted: Sat Sep 15, 2018 1:11 pm
by kostek00
You know there is always that time when you search extensively for something but don't find too much about it. Then you ask somewhere for help and he/she links you to answer like it's nothing. Thanks :D

Zetsubou's code fixes all issues I had with continue button.