Roulette menu? (For lack of a better name)

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
Quadratic
Regular
Posts: 54
Joined: Fri Aug 20, 2010 10:53 pm
Projects: Dreamscape (VN)
Contact:

Roulette menu? (For lack of a better name)

#1 Post by Quadratic »

Just wondering, is it possible to make a menu that scrolls with the arrows keys, kind of like the one below?

Image

Instead of moving the highlighted area, it moves the menu instead. Is it possible to do that in Ren'py?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Roulette menu? (For lack of a better name)

#2 Post by PyTom »

While you could probably do it with a user-defined displayable, I can't think of an easy way to accomplish this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Roulette menu? (For lack of a better name)

#3 Post by Anima »

Code: Select all

    $ rllabel = [["gold",Skip()], ["silver", Skip()], ["bronze",Skip()], ["cooper",Skip()]] # A list of all menu options. Containing the name of the option and the action for the button. 
    $ buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]} # A dictionary, the keys define the visible "slots", the value the assigned name.
screen roulette:
    modal True
    python:
        if buorder["middle"] == buorder["top"]: # In this case the option above the current was selected
            rllabel = rllabel[-1:] + rllabel[:-1]
            buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]}
            #focus_down
        elif buorder["middle"] == buorder["bottom"]: # In this case the option below the current was selected
            rllabel = rllabel[1:] + rllabel[:1]
            buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]}
            #focus_up
    vbox: #Draw the menu with textboxes
        xalign 0.5
        yalign 0.5
        xmaximum 120
        textbutton(buorder["top"])  hovered SetDict(buorder, "middle", buorder["top"]) xfill True  action rllabel[0][1] 
        textbutton(buorder["middle"])  hovered SetDict(buorder, "middle", buorder["middle"]) xfill True  action rllabel[1][1] 
        textbutton(buorder["bottom"])   hovered SetDict(buorder, "middle", buorder["bottom"])  xfill True  action rllabel[2][1]
It's as close as I could get. You just need to find a way to reset the focus to the middle button. Unfortunately, that's currently not easily done.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

Quadratic
Regular
Posts: 54
Joined: Fri Aug 20, 2010 10:53 pm
Projects: Dreamscape (VN)
Contact:

Re: Roulette menu? (For lack of a better name)

#4 Post by Quadratic »

Anima wrote:

Code: Select all

    $ rllabel = [["gold",Skip()], ["silver", Skip()], ["bronze",Skip()], ["cooper",Skip()]] # A list of all menu options. Containing the name of the option and the action for the button. 
    $ buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]} # A dictionary, the keys define the visible "slots", the value the assigned name.
screen roulette:
    modal True
    python:
        if buorder["middle"] == buorder["top"]: # In this case the option above the current was selected
            rllabel = rllabel[-1:] + rllabel[:-1]
            buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]}
            #focus_down
        elif buorder["middle"] == buorder["bottom"]: # In this case the option below the current was selected
            rllabel = rllabel[1:] + rllabel[:1]
            buorder = {"top": rllabel[0][0], "middle": rllabel[1][0], "bottom": rllabel[2][0]}
            #focus_up
    vbox: #Draw the menu with textboxes
        xalign 0.5
        yalign 0.5
        xmaximum 120
        textbutton(buorder["top"])  hovered SetDict(buorder, "middle", buorder["top"]) xfill True  action rllabel[0][1] 
        textbutton(buorder["middle"])  hovered SetDict(buorder, "middle", buorder["middle"]) xfill True  action rllabel[1][1] 
        textbutton(buorder["bottom"])   hovered SetDict(buorder, "middle", buorder["bottom"])  xfill True  action rllabel[2][1]
It's as close as I could get. You just need to find a way to reset the focus to the middle button. Unfortunately, that's currently not easily done.
Hmm, I think it could be done if, instead of doing that, we just pretend to highlight the middle button, and implement a variable that increases when the focus is shifted up by 1, and decreases when the focus is down by 1. Then, when the player selects, it uses the variable to determine which option was selected?

It'd look something like this, in my idea.

Code: Select all

# In Java
int selection = 0; #assigns variable

# wheel stuff here

# arrow keys input
if (key == input.key_DOWN) 
    selection--; #lowers selection by 1
    #code for turning the wheel
if (key == input.key_UP)
    selection++; # raises selection by 1
    #code for turning the wheel goes here
if (key == input.key_ENTER)
    if (selection == 0)
    StartGame = new StartGame;
    #repeat for other options
And yeah, no clue how to implement that here. Another problem is highlighting the box. Is there anything that changes the contrast/brightness of a certain area on the screen?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]